C语言程序编写——折半查找法
#include<stdio.h>
int main()
{ int a[]={ ,折找法折半安卓天猫源码,,,,,9,8,7,6,5,4,3,1,0};
int l=0,r=,mid,x;
scanf("%d",&x);
do
{ mid=(l+r)/2;
if(a[mid]==x)break;
if(x>a[mid])r=mid-1;
else l=mid+1;
}while(l<=r);
if(a[mid]==x)
printf("a[%d]=%d\n",mid,x);
else
printf("无此数\n");
return 0;
}
2024-11-23 11:53
2024-11-23 11:25
2024-11-23 11:03
2024-11-23 10:59
2024-11-23 10:22