Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int v[250];
- int n,x;
- int nr=0;
- int deti(int li, int ls)
- {
- if(li==ls)
- {
- if(v[li]==x)
- {nr++;
- return nr;}
- }
- else
- {
- int mij,s1,s2;
- mij=(li+ls)/2;
- s1=deti(li,mij);
- s2=deti(mij+1,ls);
- if(s1 || s2)
- return nr;
- // else
- // exit(-1);
- }
- }
- int main()
- {
- int i,n;
- cin>>n;
- for(i=1;i<=n;++i)
- cin>>v[i];
- // int x;
- cin>>x;
- cout<<deti(1,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement