Ankit_132

C

Jun 26th, 2024
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int t;
  7.     cin >> t;
  8.     while(t--){
  9.         int n;
  10.         cin>>n;
  11.        
  12.         if(n % 2 == 0){
  13.             for(int i = 1; i <=n/2; i++)
  14.                 cout << i << " " << n-i+1 << " ";
  15.         }else{
  16.             for(int i = 1; i <=n/2; i++)
  17.                 cout << i << " " << n-i << " ";
  18.             cout << n;
  19.         }
  20.         cout << endl;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment