Sequence Equation
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x,y,i;
cin>>n; //Size of array
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i]; // input array
}
for(x=1;x<=n;x++)
{
for(i=0;i<n;i++) // for loop to find the position value x in the array a
{
if(x==a[i])
{
y=i+1;
break;
}
}
for(i=0;i<n;i++) //for loop to find the position of value y in array a
{
if(y==a[i])
{
cout<<i+1<<endl;
break;
}
}
}
return 0;
}
Sequence Equation Hackerrank Solution in Cpp
0 Comments