I'm in an introductory course, and my professor is not very good. I've been working on this problem, but as of now, I'm stuck. Essentially, we have to declare a matrix of grades and create a "Z" formation. Using the "Z" locations we have to average and print grades. Here are the parameters:
Declare an 8 x 8 matrix and an array of length 22.
(declare any other variable that you use in the algorithm)
1.- Populate the matrix.
2.- Copy the elements of the first row of the matrix, the anti-diagonal, and the last row of the matrix into the array.
(we call this in class the Z in the matrix)
3.- Sort the array.
4.- Assuming that the data in the arrays are grades, compute the average of the grades stored in the even locations of the array.
5.- Copy the array back into the matrix.(back into the Z)
6.- Print out the matrix values.
This is what I have so far:
Declare an 8 x 8 matrix and an array of length 22.
(declare any other variable that you use in the algorithm)
1.- Populate the matrix.
2.- Copy the elements of the first row of the matrix, the anti-diagonal, and the last row of the matrix into the array.
(we call this in class the Z in the matrix)
3.- Sort the array.
4.- Assuming that the data in the arrays are grades, compute the average of the grades stored in the even locations of the array.
5.- Copy the array back into the matrix.(back into the Z)
6.- Print out the matrix values.
This is what I have so far:
Code:
Var k=0;
Var j=0;
Var i=0;
Var x=0;
for (k=0;k<8;k++){
x[j]=mat[i][k]
j=j+1
}
var x = new array (22);
j=8;
k=j;
for(i=1;i<7;i++){
k[j]mat[i][k];
j=j+1;
}
var mat=new array (8);
i=7
for(i=0;1<21;i=i+1){
for(k=i+1;k<22;k=k+1){
if(x[i]>x[k]){
temp=x[i];
x[i]=x
x[k]=temp
}
}
}
x[i]=mat[i][k];
mat[i][k]=x[j]
Comment