----------------解决方案--------------------------------------------------------
晕 怎么还在发帖子啊 没看到我二楼发的嘛 while 拼写错了 ...汗~~ 这么多人在这...///
----------------解决方案--------------------------------------------------------
#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);
getchar();
if(c=='n'||c=='Y')
flag=0;}
}
写程序格式要写的规范一点,这样易于见错和调试
----------------解决方案--------------------------------------------------------
.....................5555555555 感激啊 我英语其实挺好的 怎么会这样啊 谢谢大虾们
----------------解决方案--------------------------------------------------------