标签:== amp include 搜索 return class 输入 二分查找 个数
/*非递归二分查找*/ #include<stdio.h> void main(){ int a[10]={11,21,31,41,51,61,71,81,91,101}; int low=0,high=9; int key; printf("请输入要查找的数:"); scanf("%d",&key); while(low<=high){ int mid=(low+high)/2; if(a[mid]==key){ printf("该数是第 %d 个数。",mid); return; }else if(a[mid]<key){ low=mid+1; }else{ high=mid-1; } } printf("查找失败!"); }
标签:== amp include 搜索 return class 输入 二分查找 个数
原文地址:https://www.cnblogs.com/zili/p/9906070.html