fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MX = 1000 + 10;
  5.  
  6.  
  7. int main() {
  8. int t;
  9. cin >> t;
  10.  
  11. while(t > 0) {
  12. int n;
  13.  
  14. cin >> n;
  15.  
  16. int** tab = new int*[n];
  17. for(int i = 0; i < n; ++i)
  18. tab[i] = new int[n];
  19.  
  20. for(int i = 0; i < n; i++) {
  21. for(int j = 0; j < n; j++) {
  22. cin >> tab[i][j];
  23. }
  24. }
  25. for(int j = 0; j < n; j++) {
  26. for(int i = 0; i < n; i++) {
  27. cout << tab[i][j] << " ";
  28. }
  29. cout << "\n";
  30. }
  31.  
  32. for(int i = 0; i < n; ++i) {
  33. delete [] tab[i];
  34. }
  35. delete [] tab;
  36. --t;
  37. }
  38. }
Success #stdin #stdout 0s 15240KB
stdin
1
2
1 2
3 4
stdout
1 3 
2 4