Created
December 4, 2019 12:17
-
-
Save mk6619/c92e8c73eaf5ccad620bd8d81cc63eb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| int main() { | |
| //code | |
| int testCases; | |
| cin>>testCases; | |
| for(int i = 0 ; i < testCases; i++) { | |
| int n; | |
| cin>>n; | |
| int arr[n]; | |
| for(int j =0 ; j < n ; j++) { | |
| cin>>arr[j]; | |
| } | |
| int arr_n[n]; | |
| int left =0, right= n-1; | |
| int index = 0; | |
| while(index <n) { | |
| if(index%2==0) { | |
| arr_n[index] = arr[right]; | |
| right--; | |
| } else { | |
| arr_n[index] = arr[left]; | |
| left++; | |
| } | |
| index++; | |
| } | |
| for(int j =0 ; j < n ; j++) { | |
| cout<<arr_n[j]<<" "; | |
| } | |
| cout<<"\n"; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment