//1.将a,b两个数互换.
#include <stdio.h>
#include <stdlib.h>
int main() {
int a = 66, b = 88, c;
c = a;
a = b;
b = c;
printf(“a = %d, b = %d\n”, a, b);
system(“pause”);
return 0;
}
//2.将a,b两个数互换,不创建临时变量.
#include <stdio.h>
#include <stdlib.h>
int main() {
int a = 66, b = 88;
a = a + b;
b = a - b;
a = a - b;
printf(“a = %d, b = %d\n”, a, b);
system(“pause”);
return 0;
}
两种方式交换数
最新推荐文章于 2022-08-20 10:31:44 发布