Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int cauta(int v[], int n, int x){
- int st=0;
- int dr=n-1;
- while(st<=dr)
- {
- int mid = (st+dr)/2;
- if (v[mid]==x) return mid;
- if (v[mid] < x) st = mid+1;
- else dr = mid-1;
- }
- return -1;
- }
- int main()
- {
- int sir[13] = {1,3,5,6,7,9,10,12,13,15,18,19,20};
- cout << cauta(sir, 13, 19) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement