画折线图
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
void hDrawk(char c[]);
void vDrawk(char c[]);
void Drawfline(int b[]);
int xs=48,ys=50;
void hDrawk(char c[])
{
int i,j=65;
line(65,360,565,360);
for(i=0;i<11;i++)
{
line(j,375,j,360);
itoa(i,c,10);
outtextxy(j,380,c);
j+=xs;
}
}
void vDrawk(char c[])
{
int i,j=360;
line(65,80,65,360);
for(i=0;i<=5;i++)
{
line(45,j,65,j);
itoa(i,c,10);
outtextxy(35,j,c);
j-=ys;
}
}
void Drawfline(int b[])
{
int i,j=65;
moveto(j,360-(b[0]*ys));
for(i=0;i<9;i++)
{
lineto(j+xs,360-(b[i]*ys));
j+=xs;
}
}
void main()
{
int i;
int gdriver=DETECT,gmode=0;
int b[]={1,4,2,5,3,5,1,4,2,3};
char c[10];
initgraph(&gdriver,&gmode,"");
outtextxy(150,70,"the value along with the month changing!");
hDrawk(c);
outtextxy(580,365,"month");
vDrawk(c);
outtextxy(65,70,"value");
Drawfline(b);
getch();
closegraph();
}
|