Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- ifstream fin ("nivele.in");
- ofstream fout ("nivele.out");
- int t[101],n,k,x,niv;
- int main()
- {
- int i,x,y;
- fin>>n;
- for (i=1;i<=n;i++)
- fin>>t[i];
- fin>>k;
- for (i=1;i<=k;i++)
- {
- fin>>x;
- niv=1;
- while (t[x]!=0)
- {
- niv++;
- x=t[x];
- }
- fout<<niv<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement