发布网友 发布时间:2022-05-20 11:36
共1个回答
热心网友 时间:2023-10-17 23:08
#includevoidmain(){inta[10]={9,16,25,32,2,1,29,81,36,21};intkey,low=0,high=10-1,mid,k=-1;inti,j,t;printf("pleaseinput:");scanf("%d",&key);for(i=0;ia[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;}}while(low<=high){mid=(low+high)/2;if(a[mid]==key){k=mid;break;}elseif(a[mid]