Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<list>
- using namespace std;
- int main()
- {
- int n,s,i,data[50],link[50],item,ptr;
- cin>>n;
- cin>>s;
- for(i=0;i<n;i++)
- {
- cin>>data[i]>>link[i];
- }
- ptr=s;
- cin>>item;
- while(ptr!=-1)
- {
- if(item==data[ptr])
- cout<<"found";
- else
- ptr=link[ptr];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement