fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MX = 1000 + 10;
  5. int t, n, tab[MX][MX], i, j;
  6.  
  7. int main() {
  8. cin >> t;
  9.  
  10. while(t > 0) {
  11.  
  12. cin >> n;
  13. for(i = 0; i < n; i++) {
  14. for(j = 0; j < n; j++) {
  15. cin >> tab[i][j];
  16. }
  17. }
  18. for(j = 0; j < n; j++) {
  19. for(i = 0; i < n; i++) {
  20. cout << tab[i][j] << " ";
  21. }
  22. cout << "\n";
  23. }
  24. --t;
  25. }
  26. }
Success #stdin #stdout 0s 19224KB
stdin
1
2 
1 2
3 4
stdout
1 3 
2 4