鱼C论坛

 找回密码
 立即注册
查看: 1754|回复: 2

[已解决]求帮忙看下,错在哪里了

[复制链接]
发表于 2018-5-24 08:05:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#define M 10;
#include <stdio.h>

void main()
{
        static int a[M] = {-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[mid])
        {
                low = mid;
        }
        else if(n < a[mid])
        {
                high = a[mid];
        }
        else if(n == a[mid])
        {
                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
最佳答案
2018-5-24 09:02:59
define M 10
后面不要写分号
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-5-24 09:02:59 | 显示全部楼层    本楼为最佳答案   
define M 10
后面不要写分号
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-5-24 09:11:18 | 显示全部楼层
BngThea 发表于 2018-5-24 09:02
define M 10
后面不要写分号

好的,十分感谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 10:46

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表