Ankit_132

B

Jul 11th, 2023
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8. #define pb     push_back
  9.  
  10. int main()
  11. {
  12.     _test
  13.     {
  14.         int n;
  15.         cin>>n;
  16.  
  17.         vector<int> a(n);
  18.  
  19.         int m = n/2;
  20.  
  21.         a[m] = 1;
  22.  
  23.         if(n == 1)
  24.         {
  25.             for(auto e: a)
  26.                 cout<<e<<" ";
  27.             cout<<"\n";
  28.             continue;
  29.         }
  30.  
  31.         if(n==2)
  32.         {
  33.             a[0] = 2;
  34.             for(auto e: a)
  35.                 cout<<e<<" ";
  36.             cout<<"\n";
  37.             continue;
  38.         }
  39.  
  40.         a[0] = 2;
  41.         a[n-1] = 3;
  42.  
  43.         for(int i=1, x=4; i<n-1; i++)
  44.         {
  45.             if(i == m)      continue;
  46.             a[i] = x++;
  47.         }
  48.  
  49.         for(auto e: a)
  50.             cout<<e<<" ";
  51.         cout<<"\n";
  52.     }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment