#include <iostream> using namespace std; int potega2(int index) { int potegi[21] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576}; return potegi[index]; } int main() { int n,t; cin >> n >> t; int iloscKart = potega2(n); int *tablica = new int[iloscKart]; for (int i = 0; i < iloscKart; i++) cin >> tablica[i]; if (t%2 == 1) { for (int i = 0; i < iloscKart; i++) cout << tablica[iloscKart - 1 - i] << " "; } else { for (int i = 0; i < iloscKart; i++) cout << tablica[i] << " "; } delete [] tablica; 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 | #include <iostream> using namespace std; int potega2(int index) { int potegi[21] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576}; return potegi[index]; } int main() { int n,t; cin >> n >> t; int iloscKart = potega2(n); int *tablica = new int[iloscKart]; for (int i = 0; i < iloscKart; i++) cin >> tablica[i]; if (t%2 == 1) { for (int i = 0; i < iloscKart; i++) cout << tablica[iloscKart - 1 - i] << " "; } else { for (int i = 0; i < iloscKart; i++) cout << tablica[i] << " "; } delete [] tablica; return 0; } |