第一种:使用中间变量
#include <stdio.h>
int main()
{
inta=1,b=2,c;
c=a;
a=b;
b=c;
printf("%d,%d",a,b);
return 0;
}
第二种:
#include <stdio.h>
int main()
{
inta=1,b=2,c;
c=a;
a=b;
b=c;
printf("%d,%d",a,b);int a = 1, b = 2;
a = a + b;
b = a - b;
a = a - b;
printf(“%d%d”, a, b);
或者:
a = a * b;
b = a / b;
a = a / b;
return 0;
}
第三种:
#include <stdio.h>
int main()
{
inta=1,b=2,c;
c=a;
a=b;
b=c;
printf("%d,%d",a,b);int a = 1, b = 2;
a ^= b;
b ^= a;
a ^= b;
printf(“%d,%d”, a, b);
return 0;
}
网友评论