回复 7楼 autumn2779
我想scanf是没有问题的 我在听取大家的意见后直接对v[N]进行初始化也没用
#include"stdio.h"
#define N 10
main()
{
int i, x, low, high, mid;
int v[N] = {2,3,4,5,6,7,8,9,10,11};
x = 10;
//printf("please input the numbers.\n");
//for(i=0; i<N; i++)
// scanf("%d", v);
high = N - 1;
low = 0;
while(high >= low)
{
mid = (high + low) / 2;
if(x > v[mid])
low = mid + 1;
else if(x < v[mid])
high = mid - 1;
else
printf("%d", mid);
break ;//此处我听取大家意见加了break
}
}