#include<stdio.h>
#define N 15
void main()
{
int found,loca,flag=1,sign=0;
char c;
int a[N],mid,top,low,i;
printf("input:\n");
for(i=0;i<=N-1;i++)
{printf("a[%d]=",i);
scanf("%d",&a[i]);
printf("\n");}
while(flag==1)
{printf("input your number:");
scanf("%d",&found);
if(found<a[0]||found>a[N-1])
loca=-1;
low=0,top=N-1;
whlie(!sign&&(low<top))
{
mid=(top+low)/2;
if(found==a[mid])
{printf("position is %d",mid+1);
sign=1;}
if(found>a[mid])
low=mid+1;
if(found<a[mid])
top=mid-1;
};
if((!sign)||loca==-1)
printf("can not find");
printf("(y/n):");
scanf("%c",&c);
if(c=='n'||c=='Y')
flag=0;}}
提示说缺了;号 找了N久 还是不知道 求高手指教
[此贴子已经被作者于2006-7-13 19:40:08编辑过]