Promi_38

cf 1454A

Jan 18th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 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.         if(n == 1) printf("%d ", n);
  13.         else if(n % 2 == 0)
  14.         {
  15.             for(int i = n, j = 1; i >= 1; i -= 2, j += 2)
  16.             {
  17.                 printf("%d %d ", i, j);
  18.             }
  19.         }
  20.         else
  21.         {
  22.             printf("%d ", n);
  23.             for(int i = n - 2, j = 2; i >= 1; i -= 2, j += 2)
  24.             {
  25.                 printf("%d %d ", i, j);
  26.             }
  27.         }
  28.         printf("\n");
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment