//Damian Kalwa #include <iostream> using namespace std; int main() { int n; int test; cin >> n >> test; int tablica[1100000]; int kart=2; int i; int krok; for (i=1; i<n; i++){ kart=kart*2; } for (i=0; i<kart; i++){ cin >> tablica[i]; } if (test % 2 == 0) { for (i=0; i<kart; i++){ cout << tablica[i]<<" "; } } else { for (i=kart-1; i>=0; i--){ cout << tablica[i]<<" "; } } getchar(); 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 | //Damian Kalwa #include <iostream> using namespace std; int main() { int n; int test; cin >> n >> test; int tablica[1100000]; int kart=2; int i; int krok; for (i=1; i<n; i++){ kart=kart*2; } for (i=0; i<kart; i++){ cin >> tablica[i]; } if (test % 2 == 0) { for (i=0; i<kart; i++){ cout << tablica[i]<<" "; } } else { for (i=kart-1; i>=0; i--){ cout << tablica[i]<<" "; } } getchar(); return 0; } |