Codeforces 1462A. Favorite Sequence Solution
Solution in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,n,i;
- cin>>t;
- while(t--)
- {
- cin>>n;
- int a[n+5];
- for(i=0; i<n; i++)
- {
- cin>>a[i];
- }
- if(n%2==0)
- {
- for(i=0; i<n/2; i++)
- cout<<a[i]<<" "<<a[n-1-i]<<" ";
- }
- else
- {
- for(i=0; i<n/2; i++)
- cout<<a[i]<<" "<<a[n-1-i]<<" ";
- cout<<a[n/2]<<endl;
- }
- cout<<endl;
- }
- }
No comments