当前位置:首页 > 浙大远程2015年春程序设计基础(C)离线作业答案 - 图文
3.采用折半查找,在数组a[SIZE]={2, 3,20,58, 72, 76,78,87,90,900}中,找到87,然后进行删除。 答:
#include
int a[10]={2,3,20,58,72,76,78,87,90,900}; int i,mid,low=0,high=9,found; printf(\输入要查找的数:\ scanf(\ while(high>=low) { mid=(low+high)/2; if(a[mid] else if(a[mid]>found) high=mid; else break; } printf(\的下标为%d \\n\ printf(\删除%d后,新数组为:\ for(i=mid;i<9;i++) a[i]=a[i+1]; 49 for(i=0;i<9;i++) printf(\ \ printf(\ return 0; } 50
共分享92篇相关文档