So I have this homework, to print a matrix with 3 rows and 4 colums so far that I manage to do it somehow(mostly by reading this forum), since our profesor in University won't explain how this things are done. So cut to the point. My code looks like this. I manage to print the matrix , then I really don't know how those things works , so I try to just move row 1 in temp matrix , then move it back. But this really dosen't look right but I really dont know any other way to do that. What should I do?
int matrix[3][4] = { { 1,2,3,3 },{ 4,5,6,2 },{ 7,8,9,3 } };
int temp[3][4];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++)
cout << " " << matrix[i][j];
cout << endl;
}
for (int i = 0; i < 3; i++) {
temp[1][4] = matrix[1][4];
matrix[3][4] = matrix[1][4];
matrix[1][4] = temp[1][4];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++)
cout << " " << matrix[i][j];
cout << endl;
}
return 0;
}