#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
class graph
{
int num[50];
public:
graph();
void drawGraph();
}
graph::graph()
{
randomize();
for(int i=0; i<50; i++)
num[i]=random(20);
}
void graph::drawGraph()
{
int barWidth = (getmaxx()-50)/50;
int left=10, bottom=getmaxy()-50,tetxx=10;
outtextxy(getmaxx()/2,getmaxy()-10,"Overs");
outtextxy(getmaxx()-textwidth("runs"),getmaxy()/2,"Runs");
//rectangle(int left, int top, int right, int bottom);
rectangle(left, 10, getmaxx()-50, bottom);
for(int i=0;i<50; i++)
{
if(num[i]<=5)
setfillstyle(2,GREEN);
else if(num[i]<=10)
setfillstyle(4,BLUE);
else if(num[i]<=15)
setfillstyle(6,YELLOW);
else
setfillstyle(8,RED);
bar3d(left, bottom-(num[i]*8), left+barWidth, bottom,1, 1);
left+=barWidth;
}
}
void main()
{
clrscr();
int gdriver = DETECT, gmode;
/* initialize graphics, local variables */
initgraph(&gdriver, &gmode, "");
setbkcolor(BLACK);
graph g;
g.drawGraph();
getch();
closegraph();
}