#include <stdio.h>

// TODO 1: 두 정수의 주소를 받아 값을 교환하는 swap 함수를 완성하세요.
void swap(int *x, int *y) {
    int temp = *x;
    *x = *y;
    *y = temp;// 여기에 코드 작성
    
}

int main() {
    int a = 10, b = 20;

    printf("변경 전: a = %d, b = %d\n", a, b);

    // TODO 2: swap 함수를 호출하여 a와 b의 값을 바꾸세요. (주소 전달 필요)
    swap(&a, &b);

    printf("변경 후: a = %d, b = %d\n", a, b);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: