define and function
now define a function,and it will be very interesting! It can change the value of a,b.
1 #include <stdio.h>
2
3 //liang dao yishang
4 #define exchange(a,b) {\
5 int t;\
6 t = a;\
7 a=b;\
8 b=t;\
9 }
10
11 int main()
12 {
13 int a=10,b=9;
14
15 printf("a=%d \nb=%d\n",a,b);
16
17 exchange(a,b);
18 printf("a=%d \nb=%d\n",a,b);
19
20 return 0;
21 }
2
3 //liang dao yishang
4 #define exchange(a,b) {\
5 int t;\
6 t = a;\
7 a=b;\
8 b=t;\
9 }
10
11 int main()
12 {
13 int a=10,b=9;
14
15 printf("a=%d \nb=%d\n",a,b);
16
17 exchange(a,b);
18 printf("a=%d \nb=%d\n",a,b);
19
20 return 0;
21 }

浙公网安备 33010602011771号