不使用临时变量交换两个值
#include<conio.h>void main()
#include <conio.h> void main()
{
{
clrscr();
clrscr();
int a,b;
int a,b;
cout<<“Enter value of a:”;
cout <<“输入a的值:”;
cin>>a;
cin >> a;
cout<<“Enter value of b:”;
cout <<“输入b的值:”;
cin>>b;
cin >> b;
a=a+b; b=a-b; a=a-b;
a = a + b; b = ab; a = ab;
cout<<“na=”<<a; cout<<“nb=”<<b; getch(); }
cout <<“ na =” << a; cout <<“ nb =” << b; getch(); }
翻译自: https://www.thecrazyprogrammer.com/2011/12/c-program-to-swap-to-numbers-without.html
不使用临时变量交换两个值