


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <iostream> using namespace std; int main() { int N = 0, M = 0, i, j; cin >> N >> M; int* basket = new int[N]; for (int l = 0; l < N; l++) { basket[l] = l + 1; } while (M––) { cin >> i >> j; int tmp = basket[i – 1]; basket[i – 1] = basket[j – 1]; basket[j – 1] = tmp; } for (int l = 0; l < N; l++) { cout << basket[l] << ‘ ‘; } cout << endl; return 0; } | cs |