#include <iostream> using namespace std; int main() { int i,k,t; int n = 2; cin>>k; cin>>t; for(i=0;i<k-1;i++) n = n*2; int tab[n]; for(i=0;i<n;i++) cin>>tab[i]; if(t%2 == 0) for(i=0;i<n;i++) cout<<tab[i]<<"\t"; else for(i=n-1;i>=0;i--) cout<<tab[i]<<"\t"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> using namespace std; int main() { int i,k,t; int n = 2; cin>>k; cin>>t; for(i=0;i<k-1;i++) n = n*2; int tab[n]; for(i=0;i<n;i++) cin>>tab[i]; if(t%2 == 0) for(i=0;i<n;i++) cout<<tab[i]<<"\t"; else for(i=n-1;i>=0;i--) cout<<tab[i]<<"\t"; return 0; } |