#include <iostream> using namespace std; int main() { int potegi[21]; potegi[0] = 1; int n, t, i, j; cin >> n >> t; for(int i=1; i<=n; i++) potegi[i] = potegi[i-1]*2; int input[potegi[n]]; int reverse[potegi[n]]; for(i=0; i<potegi[n]; i++) cin >> input[i]; for(i=0, j=potegi[n]-1; i<potegi[n]; i++, j--) reverse[i] = input[j]; if(t%2==0) for(i=0; i<potegi[n]; i++) cout << input[i] << " "; else for(i=0; i<potegi[n]; i++) cout << reverse[i] << " "; 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 | #include <iostream> using namespace std; int main() { int potegi[21]; potegi[0] = 1; int n, t, i, j; cin >> n >> t; for(int i=1; i<=n; i++) potegi[i] = potegi[i-1]*2; int input[potegi[n]]; int reverse[potegi[n]]; for(i=0; i<potegi[n]; i++) cin >> input[i]; for(i=0, j=potegi[n]-1; i<potegi[n]; i++, j--) reverse[i] = input[j]; if(t%2==0) for(i=0; i<potegi[n]; i++) cout << input[i] << " "; else for(i=0; i<potegi[n]; i++) cout << reverse[i] << " "; return 0; } |