Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int n;
- void swap_cow(int** a)
- {
- int rg, lf;
- if (n % 2 == 0)
- {
- rg = n / 2;
- lf = rg - 1;
- }
- else
- {
- rg = n / 2;
- lf = 0;
- }
- for (int i = 0; i < n; ++i)
- {
- int buff = a[i][rg];
- a[i][rg] = a[i][lf];
- a[i][lf] = buff;
- }
- }
- int main()
- {
- cin >> n;
- int** a = new int* [n];
- for (int i = 0; i < n; ++i)
- a[i] = new int[n];
- for (int i = 0; i < n; ++i)
- for (int j = 0; j < n; ++j)
- cin >> a[i][j];
- swap_cow(a);
- for (int i = 0; i < n; ++i)
- {
- for (int j = 0; j < n; ++j)
- cout << a[i][j] << '\t';
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement