Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define N 10
- using namespace std;
- void swap(int** a, int** b) { //вважається що a[] і b[] мають однаковий розмір!!!
- int* bkp = *a;
- *a = *b;
- *b = bkp;
- }
- int main() {
- int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- int b[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
- for (int i = 0; i < N; i++) {
- cout << a[i] << ' ';
- }
- cout << endl;
- for (int i = 0; i < N; i++) {
- cout << b[i] << ' ';
- }
- cout << endl;
- cout << endl << endl;
- swap(a, b);
- for (int i = 0; i < N; i++) {
- cout << a[i] << ' ';
- }
- cout << endl;
- for (int i = 0; i < N; i++) {
- cout << b[i] << ' ';
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement