Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool BinSearch(ref long[] N, long key)
- {
- long l = -1, r = N.Length, m = 0;
- while (l < r - 1)
- {
- m = (l + r) / 2;
- if (N[m] < key)
- l = m;
- else
- r = m;
- }
- if (r == N.Length)
- return false;
- else if (N[r] == key)
- {
- N[r] = -1;
- return true;
- }
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement