Take as input N, a number. Take N more inputs and store that in an array. Write a recursive function which inverses the array. Print the values of inverted array
Input Format
Enter a number N and take N more inputs
Constraints
None
Output Format
Display the values of the inverted array in a space separated manner
Sample Input
5
0
2
4
1
3
Sample Output
0 3 1 4 2
My code:
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int i=0;
while(i<n){
a[a[i]]=i;
i=i+1;
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}