Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Swap1(int* a, int* b) {
- int temp = *a;
- *a = *b;
- *b = temp;
- }
- void Swap2(int& a, int& b) {
- int temp = a;
- a = b;
- b = temp;
- }
- int main() {
- setlocale(LC_ALL, "ru");
- int a = 5, b = 10;
- cout << a << " " << b << endl;
- Swap1(&a, &b);
- cout << a << " " << b << endl;
- Swap2(a, b);
- cout << a << " " << b << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement