#include <stdio.h> #include <stdlib.h> int main() { int N,T,t,n,*L; scanf("%d %d",&N,&T); n = 1; t = 0; while (t < N) { n *= 2; t++; } L = (int*) malloc(n*sizeof(int)); for (t = 0; t < n; t++) scanf("%d",L+t); if (T & 1) for (t = n-1; t >= 0; t--) printf("%d ",L[t]); else for (t = 0; t < n; t++) printf("%d ",L[t]); 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 | #include <stdio.h> #include <stdlib.h> int main() { int N,T,t,n,*L; scanf("%d %d",&N,&T); n = 1; t = 0; while (t < N) { n *= 2; t++; } L = (int*) malloc(n*sizeof(int)); for (t = 0; t < n; t++) scanf("%d",L+t); if (T & 1) for (t = n-1; t >= 0; t--) printf("%d ",L[t]); else for (t = 0; t < n; t++) printf("%d ",L[t]); return 0; } |