考考大家!
绘制一个两维坐标,在坐标轴上标出刻度,并用阿拉伯数字标出。根据所给点的坐标,用线段将每个点连接起来,构成一条曲线。为简单起见,曲线的数据由一维数组给定,数组元素为8个,数组如下: int data[]={7,3,12,6,9,5,8,11}
这是我做的绘直方图;
#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();
}