当前位置:编程学习 > C/C++ >>

寻求一C语言画图程序~

老师要一C语言编辑的画图程序~~ 没办法啦~~~
追问:是动态的图像吗??
答案:#include "math.h"
#include "stdio.h"
#include "graphics.h"
#include "time.h"
#define N 10000
float f1(float);
float f2(float);
main()
{float i,x,y;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
line(0,240,630,240);
line(315,0,315,480);
outtextxy(317,245,"0");
outtextxy(14,245,"-6");
outtextxy(64,245,"-5");
outtextxy(114,245,"-4");
outtextxy(164,245,"-3");
outtextxy(214,245,"-2");
outtextxy(264,245,"-1");
outtextxy(364,245,"1");
outtextxy(414,245,"2");
outtextxy(464,245,"3");
outtextxy(514,245,"4");
outtextxy(564,245,"5");
outtextxy(614,245,"6");
outtextxy(317,40,"4");
outtextxy(317,90,"3");
outtextxy(317,140,"2");
outtextxy(317,190,"1");
outtextxy(317,290,"-1");
outtextxy(317,340,"-2");
outtextxy(317,390,"-3");
outtextxy(317,440,"-4");
for(i=15;i<630;i+=50)
{putpixel(i,240,4);
putpixel(315,i+25,4);}
for(i=0;i<=N;i++)
{
x=630*i/N;
y=240-50*f1((x-315)/50);
putpixel(x,y,1);
}
for(i=0;i<=N;i++)
{
x=630*i/N;
y=240-50*f2((x-315)/50);
putpixel(x,y,4);
}
getch();
closegraph();
}
float f1(float x)
{float y;
y=x;
return(y);
}
float f2(float x)
{float y;
y=3*x;
return(y);
}

这是我编写的能绘制函数图像的程序,可也显示两个函数

上一个:C语言小程序的调试结果
下一个:C语言程序改错、填空题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,