三、程序流程图
四、代码实现
#include<bits/stdc++.h> #define N 10 using namespace std; main() { int i,a[N]={-3,4,7,9,13,45,67,89,100,180}, low=0,high=N-1,mid,k=-1,m; printf("aÊý×éÖеÄÊý¾ÝÈçÏÂ: \n"); for(i=0;i<N;i++) printf("%d ", a[i]); printf("\n"); printf("Enter m: "); scanf("%d", &m); while(low<=high) { mid=(low+high)/2; if(m<a[mid]) { high=mid-1; } else if(m>a[mid]) { low = mid+1; } else { k=mid; break; } } if(k>=0) printf("m=%d,index=%d\n",m,k); else printf("Not be found!\n"); }
标签:mid,else,5.10,low,printf,打卡 From: https://www.cnblogs.com/binglinll/p/17389499.html