Q) 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
can you tell me the additional condition required
Q) 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
can you tell me the additional condition required
hi @aggarwal.naman21
Inverse is Simply swapping the value of the array with the value at that index.
refer this code -->
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
int a[N];
for(int i =0;i<N;i++)
cin>>a[i];
int b[N];
for(int j=0;j<N;j++){
b[a[j]]=j;
}
for(int i=0;i<N;i++){
cout<<b[i]<<" ";
}
return 0;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
in the question it says recursive , what it means ?