求帮忙看下,错在哪里了
#define M 10;#include <stdio.h>
void main()
{
static int a = {-12,0,6,16,23,56,80,100,110,115};
int n, low, high, mid, fond;
low = 0;
high = M - 1;
fond = 0;
printf("input a number to be searched: ");
scanf("%d",&n);
while(1)
{
mid = (low + high) / 2;
if(n > a)
{
low = mid;
}
else if(n < a)
{
high = a;
}
else if(n == a)
{
fond = mid;
printf("他在第%d位\n",fond);
break;
}
if (low > high)
{
printf("This is a wrong number");
break;
}
}
}
为啥这么多错误,求高手指点指点
--------------------Configuration: erfenfa - Win32 Debug--------------------
Compiling...
erfenfa.c
F:\C例题\erfenfa\erfenfa.c(6) : error C2143: syntax error : missing ']' before ';'
F:\C例题\erfenfa\erfenfa.c(6) : error C2143: syntax error : missing ';' before ']'
F:\C例题\erfenfa\erfenfa.c(7) : error C2143: syntax error : missing ';' before 'type'
F:\C例题\erfenfa\erfenfa.c(8) : error C2065: 'low' : undeclared identifier
F:\C例题\erfenfa\erfenfa.c(9) : error C2065: 'high' : undeclared identifier
F:\C例题\erfenfa\erfenfa.c(10) : error C2065: 'fond' : undeclared identifier
F:\C例题\erfenfa\erfenfa.c(12) : error C2065: 'n' : undeclared identifier define M 10
后面不要写分号 BngThea 发表于 2018-5-24 09:02
define M 10
后面不要写分号
好的,十分感谢
页:
[1]