#include<stdio.h>
#define N 12
int binsearch(int *a,int key);
int main()
{
int a[] = {3,12,18,20,32,55,60,68,80,86,90,100};
int i,key;
char ch;
while(1)
{
printf("please input key");
scanf("%d",&key);
i = binsearch(a,key);
if(i == -1)
{
printf("search error\n");
}
else
{
printf("search %d at %d\n",key,i);
}
printf("continue?(Y/y)");
while(getchar()!='\n');
scanf("%c",&ch);
if(ch == 'y' || ch == 'Y')
continue;
else
break;
}
return 0;
#define N 12
int binsearch(int *a,int key);
int main()
{
int a[] = {3,12,18,20,32,55,60,68,80,86,90,100};
int i,key;
char ch;
while(1)
{
printf("please input key");
scanf("%d",&key);
i = binsearch(a,key);
if(i == -1)
{
printf("search error\n");
}
else
{
printf("search %d at %d\n",key,i);
}
printf("continue?(Y/y)");
while(getchar()!='\n');
scanf("%c",&ch);
if(ch == 'y' || ch == 'Y')
continue;
else
break;
}
return 0;