Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int x;
- int caut (int v[], int s, int d)
- {
- if(s>d)
- return -1;
- else
- {
- int m = (s+d)/2;
- if (x==v[m])
- return m;
- if (x<v[m])
- caut(v,s,m-1);
- else
- caut(v,m+1,d);
- }
- }
- int main (){
- x = 11;
- int v[10] = {5,7,9,11,12,16,19,21,23,24};
- cout << caut(v,0,9);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement