-
[C] 백준 10813 C언어IT Do/[C] 2024. 2. 15. 20:01반응형
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int N, M;
int a[101] = { 0, };
int i, j;
void swap(int i1, int i2)
{
int temp = a[i1];
a[i1] = a[i2];
a[i2] = temp;
}
int main()
{
scanf("%d %d", &N, &M);
for (int x = 1; x <= N; x++)
a[x] = x;
for (int x = 0; x < M; x++) {
scanf("%d %d", &i, &j);
swap(i, j);
}
for (int x = 1; x <= N; x++)
printf("%d ", a[x]);
return 0;
}반응형'IT Do > [C]' 카테고리의 다른 글
[C] 백준 10811 C언어 - 바구니 뒤집기 (1) 2024.02.17 [C] 백준 2480 조건문 (0) 2024.01.31 [C] 스택 구현하기 예제 (2) 2024.01.29 [C] 열거형 enum 예제 (1) 2024.01.26 [C] CRC-16 구하기 (1) 2024.01.10