二分查找
//YES_RIGHT NO_LEFT
1 //YES_RIGHT NO_LEFT 2 int bSerach(int lo, int hi, int key) { 3 while(lo <= hi) { 4 int mid = lo + (hi - lo) >> 1; 5 if(a[mid] > key) hi = mid - 1; 6 else lo = mid + 1; 7 } 8 return hi; 9 }
//YES_LEFT NO_RIGHT
//YES_LEFT NO_RIGHT int bSearch(int lo, int hi, int key) { while(lo <= hi) { int mid = lo + (hi - lo) >> 1; if(a[mid] >= key) hi = mid - 1; else lo = mid + 1; } return lo; }
It's not numeral,character and punctuation .It's my life.