使用C语言编程画图
换账号再来回答,veket的小号。。。
.......用了ege图形库.........纯体力活.........
源代码....demo.cpp.....
/////////////////////////////////////////
// ege 0.3.8
// MinGW g++ 3.4.2
// veket的小号
/////////////////////////////////////////
#include "graphics.h"
#include <stdio.h>
const int YLEN = 50;
const int XLEN = 40;
const int WIDTH = 10*XLEN;
const int HEIGHT = 2*YLEN;
const int XWIDTH = 640;
const int YHEIGHT = 480;
int main()
{
int x1, y1, x2, y2, x, y;
char strbuf[100];
int i;
setinitmode(0);
initgraph(XWIDTH, YHEIGHT);
setbkcolor(RGB(0xcc, 0xcc, 0xcc));
setfillstyle(RGB(0xff, 0xff, 0xff));
x2 = x1 = (getmaxx()-WIDTH)/2;
y1 = (getmaxy()-2*HEIGHT-YLEN)/2;
y2 = y1 + HEIGHT + YLEN;
bar(x1, y1, x1+WIDTH, y1+2*YLEN);
setcolor(RGB(0x04, 0x04, 0x04));
rectangle(x1, y1, x1+WIDTH, y1+2*YLEN);
outtextxy(x1-20, y1-10, "1");
outtextxy(x1-20, y1-10+YLEN, "0");
outtextxy(x1-20, y1-10+2*YLEN, "-1");
for(x=x1,y=y1+2*YLEN+10,i=0;x<=x1+WIDTH;x+=2*XLEN,i+=2)
{
sprintf(strbuf, "%d\0", i);
outtextxy(x, y, strbuf);
}
for(x=x1;x<x1+(int)(3*PI*XLEN);x++)
{
y = y1 + YLEN - (int)(YLEN*sin(1.0*(x-x1)/XLEN) + 0.5);
putpixel(x, y, RGB(0x3e, 0x3e, 0xff));
}
bar(x2, y2, x2+WIDTH, y2+2*YLEN);
rectangle(x2, y2, x2+WIDTH, y2+2*YLEN);
outtextxy(x2-20, y2-10, "1");
outtextxy(x2-20, y2-10+YLEN, "0.5");
outtextxy(x2-20, y2-10+2*YLEN, "0");
for(x=x2,y=y2+2*YLEN+10,i=0;x<=x1+WIDTH;x+=2*XLEN,i+=2)
{
sprintf(strbuf, "%d\0", i);
outtextxy(x, y, strbuf);
}
for(x=x2;x<x2+(int)(PI*XLEN);x++)
{
y = y2 + 2*YLEN - (int)(2*YLEN*sin(1.0*(x-x1)/XLEN) + 0.5);
putpixel(x, y, RGB(0x3e, 0x3e, 0xff));
}
for(x=x2+(int)(2*PI*XLEN);x<x2+(int)(3*PI*XLEN);x++)
{
y = y2 + 2*YLEN - (int)(2*YLEN*sin(1.0*(x-x1)/XLEN) + 0.5);
putpixel(x, y, RGB(0x3e, 0x3e, 0xff));
}
getch();
closegraph();
return 0;
}