无关紧要

zhangyihao 2021-10-24 9:10:39 1

#include

using namespace std;

int a[1000]={1,2,3,5};

int len=4;

int bin_find(int x){

int l=0,r=len,m;

while(l<r){

	m=(l+r)/2;

	if(a[m]<x){

		l=m+1;

	}else{

		r=m-1;

	}

}

if(a[m]==x) return m;

else return -1;

}

int main(){

cout<<bin_find(6);

return 0;

}

{{ vote && vote.total.up }}