#include <iostream>
int main()
{
int matrix[3][3] = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
int transpose[3][3] = {{0}};
size_t rows = sizeof matrix/sizeof matrix[0];
size_t cols = (sizeof matrix/sizeof matrix[0][0])/rows;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
transpose[j][i] = matrix[i][j];
for (int i = 0; i < cols; i++) { // matrix[rows][cols] = transpose[cols][rows]
for (int j = 0; j < rows; j++)
std::cout << transpose[i][j] << " ";
std::cout << "\n";
}
return 0;
}
/*
run:
1 4 7
2 5 8
3 6 9
*/