1 #include <stdio.h> 2 int main() 3 { 4 int a ,b,c; 5 printf("请输入第一个数字"); 6 scanf("%d",&a); 7 printf("请输入第二个数字"); 8 scanf("%d",&b); 9 printf("交换之前a=%d\tb=%d",a,b); 10 printf("\n"); 11 a = a + b; 12 b = a - b; 13 a = a - b; 14 printf("交换之后a=%d\tb=%d",a,b); 15 printf("\n"); 16 printf("---------------------------------"); 17 printf("\n"); 18 printf("交换之前a=%d\tb=%d",a,b); 19 printf("\n"); 20 a = a - b; 21 b = a + b; 22 a = b - a; 23 printf("交换之后a=%d\tb=%d",a,b); 24 printf("\n"); 25 printf("---------------------------------"); 26 printf("\n"); 27 printf("交换之前a=%d\tb=%d",a,b); 28 printf("\n"); 29 c = a; 30 a = b; 31 b = c; 32 printf("交换之后a=%d\tb=%d",a,b); 33 printf("\n"); 34 }