finished chapter 04
parent
849a032150
commit
a408616dcf
|
@ -0,0 +1,18 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define swap(T, x, y) \
|
||||
do { \
|
||||
T temp; \
|
||||
temp = x, x = y, y = temp; \
|
||||
} while (0)
|
||||
|
||||
/* swap x and y */
|
||||
int main()
|
||||
{
|
||||
int x, y;
|
||||
x = -1, y = 1;
|
||||
printf("x = %d, y = %d\n", x, y);
|
||||
swap(int, x, y);
|
||||
printf("x = %d, y = %d\n", x, y);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue