①创建临时变量
#include<stdio.h>
int main()
{
int a = 0, b = 0;
scanf("%d%d", &a, &b);
int y = 0;
y = b;
b = a;
a = y;
printf("a=%d b=%d\n", a,b);
return 0;
}
②不创建临时变量
#include<stdio.h>
int main()
{
int a = 0, b = 0;
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("a=%d b=%d", a, b);
return 0;
}