Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool binary_search(const int *a, int n, int v)
- {
- int x;
- while (n <= v) {
- int m = n + (v - n) / 2;
- if (a[m] == x)
- return m;
- if (a[m] < x)
- n = m + 1;
- else
- r = m - 1;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement