Advertisement
STANAANDREY

swap diags

Sep 17th, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, a[100][100];
  7.     cin >> n;
  8.     for (int i = 0; i < n; i++)
  9.         for (int j = 0; j < n; j++)
  10.             cin >> a[i][j];
  11.     for (int i = 0; i < n; i++)
  12.             {
  13.                 int aux = a[i][j];
  14.                 a[i][j] = a[i][n - i - 1];
  15.                 a[i][n - i - 1] = aux;
  16.             }
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         for (int j = 0; j < n; j++)
  20.             cout << a[i][j] << ' ';
  21.         cout << endl;
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement