Advertisement
Md_hosen_zisad

INCOMPLETE SEARCH

Apr 2nd, 2018
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include<iostream>
  2. #include<list>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n,s,i,data[50],link[50],item,ptr;
  7.     cin>>n;
  8.     cin>>s;
  9.     for(i=0;i<n;i++)
  10.      {
  11.  
  12.        cin>>data[i]>>link[i];
  13.      }
  14.       ptr=s;
  15.       cin>>item;
  16.     while(ptr!=-1)
  17.     {
  18.        if(item==data[ptr])
  19.           cout<<"found";
  20.        else
  21.         ptr=link[ptr];
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement