fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n, i, j;
  7. cin >> n;
  8. //if(n == 1){
  9. //int x;
  10. //cin >> x;
  11. //cout<<x<<"\n";
  12. //}
  13. int arr[n][n];
  14. for(i = 0; i < n; i++){
  15. for(j = 0; j < n; j++){
  16. cin >> arr[i][j];
  17. }
  18. }
  19. for(i = 0; i < n/2; i++){
  20. for(j = i; j < n-i-1; j++){
  21. int temp=arr[i][j];
  22. arr[i][j]=arr[n-1-j][i];
  23. arr[n-1-j][i]=arr[n-1-i][n-1-j];
  24. arr[n-1-i][n-1-j]=arr[j][n-1-i];
  25. arr[j][n-1-i]=temp;
  26. }
  27. //cout<<"\n";
  28. }
  29. for(i =0; i < n; i++){
  30. for(j = 0; j < n; j++){
  31. cout<<arr[i][j]<<" ";
  32. }
  33. cout<<"\n";
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5356KB
stdin
4
5 10 15 20
25 30 35 40
45 50 55 60
65 70 75 80
stdout
65 45 25 5 
70 50 30 10 
75 55 35 15 
80 60 40 20