// Tasowanie.cpp : Defines the entry point for the console application. // //#include "stdafx.h" #include <iostream> #include <vector> using namespace std; vector<int> V; /*void rek(int a, int b) { if (a + 1 == b) { swap(V[a], V[b]); } else { int sr = (a + b) / 2; rek(a, sr); rek(sr + 1, b); } }*/ void doIt() { int n, t; cin >> n >> t; int m = 1<<n; for (int x = 0; x < m; x++) { int a; cin >> a; V.push_back(a); } if (t % 2 == 0) { for (int x = 0; x < m; x++) { cout << V[x] << " "; } } else { for (int x = m-1; x >=0 ; x--) { cout << V[x] << " "; } } } int main() { ios_base::sync_with_stdio(0); doIt(); //system("pause"); return 0; }
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | // Tasowanie.cpp : Defines the entry point for the console application. // //#include "stdafx.h" #include <iostream> #include <vector> using namespace std; vector<int> V; /*void rek(int a, int b) { if (a + 1 == b) { swap(V[a], V[b]); } else { int sr = (a + b) / 2; rek(a, sr); rek(sr + 1, b); } }*/ void doIt() { int n, t; cin >> n >> t; int m = 1<<n; for (int x = 0; x < m; x++) { int a; cin >> a; V.push_back(a); } if (t % 2 == 0) { for (int x = 0; x < m; x++) { cout << V[x] << " "; } } else { for (int x = m-1; x >=0 ; x--) { cout << V[x] << " "; } } } int main() { ios_base::sync_with_stdio(0); doIt(); //system("pause"); return 0; } |