20 lines
347 B
C
20 lines
347 B
C
#include <stdio.h>
|
|
|
|
#define swaps(type, a, b) do { type tmp = a; a = b; b = tmp; } while(0)
|
|
|
|
void swap(int *a, int *b) {
|
|
int tmp = *a;
|
|
*a = *b;
|
|
*b = tmp;
|
|
}
|
|
|
|
int main() {
|
|
int a = 69, b = 31;
|
|
printf("%d, %d", a, b);
|
|
swap(&a, &b);
|
|
printf("Function Swap: %d, %d\n", a, b);
|
|
swaps(int, a, b);
|
|
printf("Macro Swap: %d, %d\n", a, b);
|
|
return 0;
|
|
}
|