校园网源码
2024-11-06 13:06
1.C语言程序编写——折半查找法
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-06 13:24
2024-11-06 13:19
2024-11-06 13:12
2024-11-06 12:46
2024-11-06 12:45
2024-11-06 12:42
2024-11-06 11:42
2024-11-06 11:11