int main()
{
int a[15]={1,43,67,88,90,93,101,110,123,124,333,423,567,654,743},i=7,n,t,p,q;
char c='y';
while (c=='y')
{
printf("请输入一个数字:");
scanf("%d",&n);
t=0;
q=4;
for (p=4;p>0;p--)
{
if (n==a[i])
{
printf("正确!%d是第%d个数字。\n",n,i+1);
t=1;
c='n';
break;
}
else i=(n>a[i])?i+q:i-q;
q=q/2;
}
if (t==0)
{printf("无此数\n");
printf("还要继续猜下去吗?(y/n)\n");
scanf(" %c",&c);} //此处的%前必须加空格,不加空格就没法运行??
}
return 0;
}