【C语言】二分法查找

 
  
二分法查找:
#include

int binary_search(int arr[],int key,int sz)
	{
  int left = 0;
  int right = sz-1;
  while(left<=right)
  {
int mid = left + ((right-left)>>1);


	if(arr[mid]>key)
{
	right = mid - 1;
}
else if(arr[mid]

你可能感兴趣的:(C语言)