![](https://i-blog.csdnimg.cn/blog_migrate/f3a9a53afd62c20c9383867c0dd8d06e.png)
c ++两个整数交换
#include<iostream.h>
#include<conio.h>
#define SWAP(a,b) {int temp; temp=a; a=b; b=temp;}
void main()
{
clrscr();
int x,y;
cout<<“Enter two numbers:”;
cin>>x>>y;
cout<<“x=”<<x<<” y=”<<y;
SWAP(x,y);
cout<<“nx=”<<x<<” y=”<<y;
getch();
}
#include<iostream.h>
#include<conio.h>
#define SWAP (a,b) {int temp; temp=a; a=b; b=temp;}
void main()
{
clrscr();
int x,y;
cout<<“Enter two numbers:”;
cin>>x>>y;
cout<<“x=”<<x<<” y=”<<y;
SWAP(x,y);
cout<<“nx=”<<x<<” y=”<<y;
getch();
}
翻译自: https://www.thecrazyprogrammer.com/2013/03/c-program-to-swap-two-numbers-using.html
c ++两个整数交换