Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool Cautare(int v[], int st, int dr, int x)
- {
- if(st==dr)
- {
- if(v[st]==x)
- return 1;
- else
- return 0;
- }
- else
- {
- int mij=(st+dr)/2;
- if(v[mij]>=x)
- return Cautare(v,st,mij,x);
- else
- return Cautare(v,mij+1,dr,x);
- }
- }
- int n, m, x[25001], y[2000001];
- int main()
- {
- cin >> n;
- for (int i=1; i<=n; i++)
- cin >> x[i];
- cin >> m;
- for (int i=1; i<=m; i++)
- cin >> y[i];
- for(int i=1;i<=m;i++)
- {
- int z = Cautare(x,1,n,y[i]);
- if(z==1)
- cout << 1 << " ";
- else
- cout << 0 << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement