方法一
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main()
{
int a = 4;
int b = 5;
int temp = 0;
temp = a;
a = b;
b = temp;
printf("a=%d b=%dn", a, b);//借助temp变量
return 0;
}
方法二
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main()
{
int a = 4;
int b = 5;
a = a + b;//9
b = a - b;//4
a = a - b;//5
printf("a=%d b=%dn", a, b);//加减法
return 0;
}
方法三
#define _CRT_SECURE_NO_WARNINGS 1
#include
int main()
{
int a = 4;//...0100
int b = 5;//...0101
a = a ^ b;//...0001
b = a ^ b;//...0100
a = a ^ b;//...0101
printf("a=%d b=%dn", a, b);//应用a^b^b==a,异或
return 0;
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net