fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int test, count = 1;
  7. cin >> test;
  8. while(test--){
  9. int n, i, j;
  10. cin >> n;
  11. int arr[n][n];
  12. cout<<"Test Case #"<<count<<":"<<"\n";
  13. for(int i = 0; i < n; i++){
  14. for(int j = 0; j < n; j++){
  15. cin >> arr[i][j];
  16. }
  17. }
  18. for(i = 0; i < n/2; i++){
  19. for(j = i; j < n-i-1; j++){
  20. int temp=arr[i][j];
  21. arr[i][j]=arr[n-1-j][i];
  22. arr[n-1-j][i]=arr[n-1-i][n-1-j];
  23. arr[n-1-i][n-1-j]=arr[j][n-1-i];
  24. arr[j][n-1-i]=temp;
  25. }
  26. }
  27. for(i =0; i < n; i++){
  28. for(j = 0; j < n; j++){
  29. cout<<arr[i][j]<<" ";
  30. }
  31. cout<<"\n";
  32. }
  33. count++;
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5464KB
stdin
4
1
1
2
1 2
4 3
3
1 2 3
8 9 4
7 6 5
5
-44 25 -52 69 -5 
17 22 51 27 -44 
-79 28 -78 1 -47 
65 -77 -14 -21 -6 
-96 43 -21 -20 90 
stdout
Test Case #1:
1 
Test Case #2:
4 1 
3 2 
Test Case #3:
7 8 1 
6 9 2 
5 4 3 
Test Case #4:
-96 65 -79 17 -44 
43 -77 28 22 25 
-21 -14 -78 51 -52 
-20 -21 1 27 69 
90 -6 -47 -44 -5