### Problem with matrix

Hello I am completely stuck with my matrix problem.
First funktion should read numbers one by one to the square matrix. Matrix rotate90deg function should create new matrix which has rotated 90 degrees compared to the original matrix. The last function should print original matrix. I have also header file where
typedef std::vector<std::vector<int>> Matrix;
is defined. What is wrong with this idea ?

Thanks for help :)
 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` `````` #include #include #include "matrix.hpp" // Assumes 'm' is a square matrix Matrix readMatrix(int n) { Matrix matrix; for (int i = 0; i> matrix[j][i]; } std::cout << "" << std::endl; } return matrix; } Matrix rotate90deg(Matrix & m) { Matrix temp = m; for (unsigned int i = 0; i
What is the size of 'matrix' after line 9?

The vector has both operator[] and member at(). They have a tiny difference. If you would use the at() on line 12, you would notice.

Why the printout on line 15?

On rotate90deg ... isn't that called transpose?
What if you don't have a square matrix?
Why the copy on line 22?

The print() again assumes a square matrix. The m is a vector and has m.size() vector<int> in it, but how many elements each of those m.size() vector<int> does have?
Topic archived. No new replies allowed.