这是我做的绘直方图;
#include <graphics.h>
#include <conio.h>
void draw(int x,int y,int high)
{
bar(x,y-high*10,x+20,y);
}
main()
{
int driver=DETECT, mode=0,i;
char *x_string[]={"1","2","3","4","5","6","7","8"};
char *y_string[]={"0","1","3","5","7","9","11","13"};
int data[]={7,3,12,6,9,5,8,11};
initgraph(&driver,&mode,"c:\\TC");
setfillstyle(SOLID_FILL,BLUE);
bar(0,0,639,479);
setfillstyle(SOLID_FILL,RED);
bar(100,340,550,341);
bar(100,100,101,340);
for(i=0;i<8;i++)
{moveto(80,340-20*i) ;
outtext(y_string[i]);
moveto(150+50*i,350);
outtext(x_string[i]);
draw(150+50*i,340,data[i]);
}
getch();
}