C语言电梯编程错误 错误 noname.c 136: 表达式语法错在 main 函数中 帮忙改一下 很感谢
#include<graphics.h>
#include<stdlib.h>
#include<time.h>
#include<dos.h>
#define ESC 0x011b
#define z 0x2c7a
#define s 0x1f73
#define d 0x2064
#define x 0x2d78
#define c 0x2e63
#define f 0x2166
void init(void);
void drawfence(void);
void opendoor(int y1);
void closedoor(int y1);
main()
{
int i,j,n,y1,floor,speed;
int key,key1;
void *map,*map1;
unsigned size;
init();
drawfence();
speed=4400;
setcolor(6);
setfillstyle(8,3);
size=imagesize(108,0,192,450);
map=malloc(size);
getimage(108,0,192,450,map);
circle(120,333,6);
outtextxy(118,331,"1");
circle(140,333,6);
outtextxy(138,331,"2");
circle(160,333,6);
outtextxy(158,331,"3");
circle(180,333,6);
outtextxy(178,331,"4");
setlinestyle(0,0,3);
setcolor(8);
rectangle(110,340,190,440);
for(i=0;i<100;i++)
line(110,340+i,190,340+i);
map1=malloc(size);
getimage(108,325,192,440,map1);
y1=340-15;
setcolor(4);
key=bioskey(0);
if(key==x||key==s)
n=2;
if(key==c||key==d)
n=3;
if(key==f)
n=4;
n=(n-1)*100;
outtextxy(458,48,"\30");
for(j=0;j<n;j++)
{
putimage(108,0,map,0);
putimage(108,y1-j-1,map1,0);
delay(speed);
}
y1=y1-j;
opendoor(y1);
do
{
floor=4-(y1/100)+48;
closedoor(y1);
key1=getch();
if((key1>48&&key1<53)||key1==27)
{
if(floor>key1&&key1!=27)
{
n=floor-key1;
n=n*100;
for(j=0;j<n;j++)
{
putimage(108,0,map,0);
putimage(108,y1+j+1,map1,0);
outtextxy(458,48,"\31");
delay(speed);
}
y1=y1+j;
setcolor(1);
outtextxy(458,48,"\31");
}
if(floor<key1)
{
n=key1-floor;
n=n*100;
for(j=0;j<n;j++)
{
putimage(108,0,map,0);
putimage(108,y1-j+1,map1,0);
outtextxy(458,48,"\30");
delay(speed);
}
y1=y1-j;
setcolor(1);
outtextxy(458,48,"\30");
}
}
opendoor(y1);
}while(key1!=27);
void init(void)
{
int gd=DETECT,gr;
initgraph(&gd,&gr,"");
cleardevice();
setbkcolor(1);
cleardevice();
}
void drawfence(void)
{
int i;
circle(440,50,8);
outtextxy(438,48,"1");
circle(460,50,8);
outtextxy(458,48,"");
circle(450,90,8);
outtextxy(448,88,"\31");
outtextxy(435,88,"f");
circle(440,190,8);
outtextxy(438,188,"\30");
outtextxy(425,188,"c");
circle(460,190,8);
outtextxy(458,188,"\31");
outtextxy(475,188,"d");
circle(440,290,8);
outtextxy(438,288,"\30");
outtextxy(425,288,"x");
circle(460,290,8);
outtextxy(458,288,"\31");
outtextxy(475,288,"s");
circle(450,390,8);
outtextxy(448,388,"\30");
outtextxy(435,388,"z");
for(i=0;i<500;i+=100)
{
line(0,40+i,105,40+i);
line(195,40+i,320,40+i);
}
line(0,40,0,440);
line(105,40,105,440);
line(195,40,195,440);
line(320,40,320,440);
}
void opendoor(int y1)
{
int i,speed;
speed=44000;
setcolor(1);
for(i=0;i<40;i++)
{
line(150-i,y1+15,150-i,y1+115);
line(150+i,y1+15,150+i,y1+115);
delay(speed);
}
}
void closedoor(int y1)
{
int i,speed;
speed=44000;
setcolor(8);
for(i=0;i<40;i++)
{
line(110+i,y1+15,110+i,y1+115);
line(190-i,y1+15,190-i,y1+115);
delay(speed);
}
}
}
[解决办法]
没有对应的库,你把错误信息贴上来
[解决办法]
偶遇到类似问题都是用
“每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。
[解决办法]
可以单步调试么?
[解决办法]
提示错误在main函数中,不过136行是在init函数块,你的main函数少了花括号了吧...