Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #define N 25005
- using namespace std;
- //ifstream fin ("eratostene1.in");
- //ofstream fout ("eratostene1.out");
- int n,i,m;
- int a[N],x;
- int st, dr, mij;
- bool gasit;
- int main()
- {
- cin>>n;
- for(i=1;i<=n;++i)
- cin>>a[i];
- cin>>m;
- while(m>0)
- {
- --m;
- cin>>x;///valorea de cautat
- ///cautarea binara
- /* st=1, dr=n;
- gasit=0;
- while(st<=dr && !gasit)
- {
- mij=(st+dr)/2;///mij=st+(dr-st)/2;
- if(x==a[mij]) gasit=1;
- else if(x>a[mij]) st=mij+1;
- else dr=mij-1;
- }*/
- gasit=binary_search(a+1,a+n+1,x);
- cout<<gasit<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement