Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int binarysearch(int a, int mass[], int n)
- {
- int low, high, middle;
- low = 0;
- high = n - 1;
- while (low <= high)
- {
- middle = (low + high) / 2;
- if (a < mass[middle])
- high = middle - 1;
- else if (a > mass[middle])
- low = middle + 1;
- else
- return middle;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement