fork download
  1. #include <ctime>
  2. #include <cstdlib>
  3. #include <iomanip>
  4. #include <iostream>
  5. using namespace std;
  6. int main(){
  7. srand(time(NULL));
  8. int n = rand() % 10 + 1, a[n][n];
  9. for(int i = 0; i < n; cout << endl, ++i)
  10. for(int j = 0; j < n; cout << setw(2) << (a[i][j++] = rand() % 10));
  11. cout << endl;
  12. for(int i = 0; i < n; cout << endl, ++i){
  13. for(int j = i + 1; j < n; swap(a[i][j++], a[j][i]));
  14. for(int j = 0; j < n; cout << setw(2) << a[i][j++]);
  15. }
  16. }
Success #stdin #stdout 0s 4328KB
stdin
Standard input is empty
stdout
 7 3 9 0 3 1 4 5 3 9
 7 3 3 0 6 1 5 5 1 2
 1 9 3 4 8 1 0 2 7 9
 1 6 3 0 9 8 3 3 5 6
 4 5 2 8 5 0 1 1 7 4
 5 9 3 1 5 2 2 5 6 1
 4 7 8 9 9 9 9 4 2 7
 3 9 2 5 7 7 7 0 0 4
 4 6 5 7 9 0 1 1 7 7
 2 4 6 2 5 7 1 5 2 6

 7 7 1 1 4 5 4 3 4 2
 3 3 9 6 5 9 7 9 6 4
 9 3 3 3 2 3 8 2 5 6
 0 0 4 0 8 1 9 5 7 2
 3 6 8 9 5 5 9 7 9 5
 1 1 1 8 0 2 9 7 0 7
 4 5 0 3 1 2 9 7 1 1
 5 5 2 3 1 5 4 0 1 5
 3 1 7 5 7 6 2 0 7 2
 9 2 9 6 4 1 7 4 7 6