- #include <iostream>
- using namespace std;
- void myswap(int &a, int &b){
- int temp;
- temp=a;
- a=b;
- b=temp;
- }
- int main() {
- int a=10;
- int b=20;
- cout << "a: " << a << endl;
- cout << "b: " << b << endl;
- myswap(a,b);
- cout << endl;
- cout << "a: " << a << endl;
- cout << "b: " << b << endl;
- return 0;
- }
Raw Paste