Hello all again I am doing my best to finish a lab I have and would be glad to be pointed in The right direction. My prof wants me to do a program to calculate a matrix using a array and then invert it. I am catching up on my matrices so it can be a little easyer :P
The programs output is the following:
This program calculates a matrix and inverts it
Original matrix
Enter the first number of column 1: 1
Enter the second number of column 1: 2
Enter the third number of column 1: 3
Enter the first number of column 2: 4
Enter the second number of column 2: 5
Enter the third number of column 2: 6
Enter the first number of column 3: 7
Enter the second number of column 3: 8
Enter the third number of column 3: 9
Original Matrix:
1 2 3
4 5 6
7 8 9
Inverted Matrix:
1 4 7
2 5 8
3 6 9
I do not pretend for anybody to do my homework just a little help and when I can I will post my code to see if I am on track.
I am guessing i should use a
Array [2][2]
A do loop with two nesteed for loops for input storing the values in two variables rows and column array [rows][column] or wait maybe that wont work meewh jajajajaj
You will need a 3x3 array for the given case, so use A[3][3]. The indexes to use are 0,1,2.
The example you gave has the rows and columns exchanged. This is the transpose of a matrix, not the inverse. Hopefully you have the task correct.
Note that for the 3x3 case you have, the transpose can be found by swapping just 3 pairs of elements (identify them by inspection).
for each line (where the spaces are needed between the values).
Then the following should work:
1 2 3 4 5 6
for (line =0; line <= 2; line++)
{
cout << "Enter the line" << line+1;// I corrected 2 syntax errors on this line
<< "of the row "<< line+1 << ": ";// right? line is actually the row# (more errors were on this line)
cin >> value[line][0] >> value[line][1] >> value[line][2];// reading all 3 values from one line of input.
}
Please compile and test your own code. You should be catching these basic syntax errors yourself.