#include <iostream>
using namespace std;
int rearrange(int a[], int n){
int b[n];
int s = 0, e = n-1;
bool flag = true;
for (int i =0;i < n;i++){
if (flag)
b[i] = a[e--];
else
b[i] = a[s++];
flag = !flag;
}
for(int i = 0; i < n; i++)
cout << b[i] << " ";
}
int main(){
int n;
cout << "Enter no.of elements:";
cin >> n;
int a[n];
for(int i = 0;i < n; i++)
cin >> a[i];
rearrange(a, n);
}
#include <iostream>
using namespace std;
int *rearrange(int a[], int n){
int *b = new int[n];
int s = 0, e = n-1;
bool flag = true;
for (int i =0;i < n;i++){
if (flag)
b[i] = a[e--];
else
b[i] = a[s++];
flag = !flag;
}
return b;
}
int main(){
int n;
cout << "Enter no.of elements:";
cin >> n;
int a[n];
for(int i = 0;i < n; i++)
cin >> a[i];
int *b = rearrange(a, n);
for(int i = 0; i < n; i++)
cout << b[i] << " ";
}