#include <stdio.h>
#include <graphics.h>
int main(void){
char* categories[] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"};
float a[] = {3.9,5.3,7.2,9.6,12.9,17.0,23.2,31.4,39.8,50.2,62.9,76.0,92.0,105.7,122.8,131.7,150.7,179.3,203.2,211.0};
char s[10];
int graphdriver = VGA;
int graphmode = VGAHI,i,j,x,n,dx,ddx,y,dy;
initgraph(&graphdriver,&graphmode,"");
cleardevice();
setviewport(20,20,570,450,1);
setcolor(1);
setbkcolor(7);
n = 20;
dx = n;
ddx = 0.8*dx;
y = 390;
for(i=0;i<=n-1;i++){
x = dx*i + 100;
dy = a[i]*1.5;
setfillstyle(1,i);
rectangle(x,y,x+ddx,y-dy);
floodfill(x+1,y-dy+1,1);
}
setcolor(WHITE);
rectangle(80,390,x+ddx+20,15);
j = 0;
for(i=108;i<=x+ddx;i+=20){
line(i,390,i,400);
outtextxy(i-4,405,categories[j]);
j++;
}
sprintf(s,"%d",j);
for(j=0;j<=300;j+=50){
line(70,390-1.5*j,80,390-1.5*j);
sprintf(s,"%d",j);
outtextxy(45,390-1.5*j-3,s);
}
outtextxy(150,420,"Every year 1990-2000");
settextstyle(0,1,1);
outtextxy(30,40,"Production");
getch();
closegraph();
return 0;
}
淘宝杜琨