2020 C Chapter 10 - 배열과 포인터

From: 2020-03-16 00:00:00 To: 2020-07-01 00:00:00 Now: 2024-05-07 21:42:52 Status: Public

C - Swap (Snippet)

Time Limit: 1s Memory Limit: 128MB

Snippet Judge Submissions: 154 Solved: 102
Description

포인터를 사용하여 swap 함수를 만들어보자.

* YOUR_CODE 부분만 작성하면 됩니다.

Input

Line 1:두 개의 숫자 a, b

Output

Line 1: a, b가 서로 바뀐 값이 출력된다.

Sample Code
#include<stdio.h>
void swap(int *a,int *b){
    YOUR_CODE
}

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    swap(&a,&b);
    printf("%d %d",a,b);
}
Sample Input
3 5
Sample Output
5 3