Advertisement
sajol222

lower

Feb 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. int lower(int a[],int n,int t)
  2. {
  3.     int m,l=0,h=n-1;
  4.     while(l<=h)
  5.     {
  6.         m=(l+h)/2;
  7.         if(a[m]==t)
  8.         {
  9.             h=m-1;
  10.         }
  11.  
  12.         else if(a[m]<t)l=m+1;
  13.         else h=m-1;
  14.     }
  15.     return m;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement