Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void swap(int a[][3], int b[][3], int r, int c);
- int main()
- {
- int a[3][3] = {
- {0, 1, 2},
- {3, 4, 5},
- {6, 7, 8}
- };
- int b[3][3] = {
- {20, 21, 22},
- {23, 24, 25},
- {26, 27, 28}
- };
- for (int r = 0; r < 3; r++)
- {
- for (int c = 0; c < 3; c++)
- {
- if (r == c)
- {
- swap(a, b, r, c);
- }
- }
- }
- cout << a[0][0];
- }
- void swap(int &a, int &b, int r, int c)
- {
- int temp = a;
- b[r][c] = a;
- a[r][c] = temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement