#include <bits/stdc++.h> using namespace std; int main() { int arr[105][105]; int cnt = 1; int i, j, t; int r = 5; int c = 5; for (i=0; i<r; ++i) { for (j=0; j<c; ++j) { arr[i][j] = cnt++; } } for (i=0; i<r; ++i) { for (j=0; j<c; ++j) { printf("%4d", arr[i][j]); } printf(" "); } printf("---------------------------- "); if (c > r) { for (i=0; i<r; ++i) for (j=i; j<c; ++j) swap(arr[i][j], arr[j][i]); } else { for (int j=0; j<c; ++j) for (int i=j; i<r; ++i) swap(arr[i][j], arr[j][i]); } for (i=0; i<c; ++i) { for (j=0; j<r; ++j) { printf("%4d", arr[i][j]); } printf(" "); } return 0; }