首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

帮小弟我看看这个程序吧,大哥们,有关问题错在哪了

2012-04-02 
帮我看看这个程序吧,大哥们,问题错在哪了?#include conio.h #include graphics.h #include stdio.h

帮我看看这个程序吧,大哥们,问题错在哪了?
#include "conio.h "
#include "graphics.h "
#include "stdio.h "
void   main()
{
char   *cat[]={ "1 ", "2 ", "3 ", "4 ", "5 ", "6 ", "7 ", "8 ", "9 ", "10 "};
float   a[]={4.9,8.3,13.9,23.32,39.8,48.9,57.0,68.78,79.7,99.2};
char   xname[]= "X ";
char   yname[]= "Y ";
char   s[10];
int   gd=DETECT,gm;
initgraph(&gd,&gm, "d:\\program\\turboc2\\bgi ");
    cleardevice();
setviewport(20,20,350,350,1);
setbkcolor(15);
    int   n=10,i,j,x,y=300;
moveto(80,y-a[0]);
for(i=1;i <n;i++)
{
x=80+n*i;
setcolor(5);
lineto(x,y-a[i]);
setcolor(8);
circle(x,y-a[i],2);
moveto(x,y-a[i]);
}
setcolor(1);
rectangle(80,y,100+n*20,15);
j=0;
for(i=100;i <=80+n*20;i++)
{
line(i,y,i,y+5);
outtextxy(i-4,y+10,cat[j]);
j++;
}
for(j=0;j <y;j+=50)
{
line(70,y-j,80,y-j);
sprintf(s, "%d ",j);
outtextxy(45,y-i-3,s);
}
outtextxy(290,y+20,xname);
settextstyle(0,1,1);
outtextxy(30,40,yname);
getch();
closegraph();
}
在TC下编译时说i,j,n,x,y都没有定义




[解决办法]
int n=10,i,j,x,y=300;将这一行放到前面

initgraph(&gd,&gm, "d:\\program\\turboc2\\bgi ");之前
[解决办法]
变量的声明放到最前面

热点排行