Skip to content

Commit

Permalink
Must Do
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish-kumar7 committed Mar 8, 2020
1 parent f5475ce commit 61ba81f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions All Other Topics/Rearrange Array Alternatively.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
//code
int t;
cin>>t;
while(t--){
int n;
cin>>n;

int A[n];
for(int i=0;i<n;i++)
{
cin>>A[i];
}
int C[n];
int j=0;
int l=0;
for(int i=0;i<n;i++)
{
if(i%2==0)
{
C[i]=A[n-j-1];
j++;
}
else
{
C[i]=A[l];
l++;

}
}

for(int k=0;k<n;k++)
{
cout<<C[k]<<" ";
}
cout<<endl;

}
return 0;
}

0 comments on commit 61ba81f

Please sign in to comment.