0

这是我的代码。它应该在每次循环 main 时绘制一个条形图。它最初正确显示条形图,但是当循环时,线条功能似乎不再起作用....有人可以帮我吗?此处提供的图形库:http ://www.mediafire.com/file/qtdy239vvr19qyi/CODE+BLOCKS+with+Graphic.h.rar 注意:我使用的是代码块 17.12

#include <graphics.h>
#include <conio.h>
#include <fstream>
#include <iostream>

using namespace std;

void graph(string f){
   cleardevice();
int gd = DETECT, gm;
initgraph(&gd, &gm, "X:\\TC\\BGI");
settextstyle(BOLD_FONT,HORIZ_DIR,2);
 outtextxy(275,0, "BAR CHART");

setlinestyle(SOLID_LINE,0,2);
/* Draw X and Y Axis */
line(90,410,90,50);            //Y axis
line(90,410,1100,410);          //X axis
line(85,60,90,50);               //Arrow code last 4 line
line(95,60,90,50);
line(1095,405,1100,410);
line(1095,415,1100,410);


line(84,360 ,95, 360);
line (84, 310 ,95,310);
line (84, 260, 95, 260);
line(84, 210, 95, 210);
line(84, 160, 95, 160);
line (84, 110, 95, 110);

outtextxy(34, 350, "50");
outtextxy(34, 300, "100");
outtextxy(34, 250, "150");
outtextxy(34, 200, "200");
outtextxy(34, 150, "250");
outtextxy(34, 100, "300");

outtextxy(150, 420, "Jan");
outtextxy(225, 420, "Feb");
outtextxy(300, 420, "Mar");
outtextxy(375, 420, "April");
outtextxy(450, 420, "May");
outtextxy(525, 420, "June");
outtextxy(600, 420, "Jul");
outtextxy(675, 420, "Aug");
outtextxy(750, 420, "Sept");
outtextxy(825, 420, "Oct");
outtextxy(900, 420, "Nov");
outtextxy(975, 420, "Dec");

outtextxy(65,60,"Y");
outtextxy(1080,415,"X");
outtextxy(70,415,"O");

/* Draw bars on screen */
//setfillstyle(XHATCH_FILL, RED);
bar(150,110,200,410);
bar(225,160,275,410);
bar(300,120,350,410);
bar(375,170,425,410);
bar(450,135,500,410);

getch();
closegraph();
//cleardevice();
}

int main(){
int choice = 1;
do{
 graph();
 cout<<"Key in zero to loop:..";
 cin>>choice;
}while (choice == 0);
 return 0;
}
4

0 回答 0