Promi_38

cf 1462A

Dec 21st, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int t;
  6.     scanf("%d", &t);
  7.    
  8.     while(t--)
  9.     {
  10.         int n;
  11.         scanf("%d", &n);
  12.         long long a[n], i, j;
  13.         for(i = 0; i < n; i++) scanf("%lld", &a[i]);
  14.        
  15.         if(n % 2 != 0)
  16.         {
  17.             for(i = 0, j = n-1; i <= n/2; i++, j--)
  18.             {
  19.                 printf("%lld ", a[i]);
  20.                 if(i == n/2) break;
  21.                 printf("%lld ", a[j]);
  22.             }
  23.         }
  24.        
  25.         else
  26.         {
  27.             for(i = 0, j = n-1; i < n/2; i++, j--)
  28.             {
  29.                 printf("%lld ", a[i]);
  30.                 printf("%lld ", a[j]);
  31.             }
  32.         }
  33.        
  34.         printf("\n");
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment