#include <stdio.h> // SWAP(x, y) 交换x,y的值 #define SWAP(x, y) \ (y) = (x) + (y); \ (x) = (y) - (x); \ (y) = (y) - (x); int main() { int a = 3-2, b = 5*8; SWAP(a, b); printf("%d, %d\n", a, b); return 0; }
运行结果:
40, 1
#include <stdio.h> // SWAP(x, y) 交换x,y的值 #define SWAP(x, y) \ (y) = (x) + (y); \ (x) = (y) - (x); \ (y) = (y) - (x); int main() { int a = 3-2, b = 5*8; SWAP(a, b); printf("%d, %d\n", a, b); return 0; }
运行结果:
40, 1