swap 함수 구현

#include <stdio.h>

void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}

int main() {
int a, b;

printf("a : ");
scanf("%d", &a);

printf("b : ");
scanf("%d", &b);

printf("\n\n(before) a = %d\n(before) b = %d\n\n", a, b);

swap(&a, &b);
printf("swapped!\n\n");

printf("(after) a = %d\n(after) b = %d\n", a, b);

return 0;
}
Total views

댓글

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×