柱状图统计


 1 #include<graphics.h>
 2 #include<math.h>
 3 #include<stdio.h>
 4 int main()
 5 {
 6     int gmode,gdriver=DETECT;
 7     int b[100][100],m,k=30,l,kk;
 8     double x1,y1,x2,y2;
 9     unsigned int i,j,a[]= {BLACK,BLUE,GREEN,CYAN,RED,BROWN,LIGHTGRAY,DARKGRAY,LIGHTBLUE,LIGHTGREEN,LIGHTRED,LIGHTMAGENTA,YELLOW,WHITE};
10     initgraph(&gdriver,&gmode,"");
11     cleardevice();
12     scanf("%d",&m);
13     for(i=0;i<m;i++)
14         for(j=0;j<3;j++)
15             scanf("%d",&b[i][j]);
16     
17         for(kk=0;kk<m;kk+=3)
18         {
19             k=30;
20             line(10,10,10,420);
21     line(5,15,10,10);
22     line(15,15,10,10);
23     line(10,425,550,425);
24     line(540,415,550,425);
25     line(540,435,550,425);
26     for(i=0;i<3;i++)
27     {
28         l=5;
29         if(i+kk>=m)
30         break;
31         for(j=0;j<3;j++)
32     {
33         setfillstyle(5,a[l++]);
34         bar3d(k,400-b[i+kk][j]*3,k+40,400,35,1);
35         k+=50;
36         }
37         k+=10;
38     }
39     
40     getch();
41     cleardevice();
42         }
43     return 0;
44 }

 


 

posted @ 2018-04-11 16:41  左手边五十米  阅读(144)  评论(0编辑  收藏  举报