Advertisement
KoBeWi

Untitled

Dec 10th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. int iter(int tab[], int x, int left, int right) {
  2.     while (left <= right) {
  3.         int mid = (left + right)/2;
  4.         if (tab[mid] == x) return mid;
  5.  
  6.         if (x < tab[mid])
  7.             right = mid - 1;
  8.         else
  9.             left = mid + 1;
  10.     }
  11.  
  12.     return -1;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement