나의정답.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
int Queue[100], front = -1, back = -1, ch[10];
vector<int> map[10];
int main(int argc, char** argv) {
//freopen("input.txt", "rt", stdin);
int a, b, x;
for (int i = 1; i <= 6; i++) {
scanf("%d %d", &a, &b);
map[a].push_back(b);
map[b].push_back(a);
}
Queue[++back] = 1;
ch[1] = 1;
while (front < back) {
x = Queue[++front];
printf("%d ", x);
for (int i = 0; i < map[x].size(); i++) {
if (ch[map[x][i]] == 0) {
ch[map[x][i]] = 1;
Queue[++back] = map[x][i];
}
}
}
return 0;
}