绘制函数曲线Word文档格式.docx
- 文档编号:7645030
- 上传时间:2023-05-08
- 格式:DOCX
- 页数:11
- 大小:39.98KB
绘制函数曲线Word文档格式.docx
《绘制函数曲线Word文档格式.docx》由会员分享,可在线阅读,更多相关《绘制函数曲线Word文档格式.docx(11页珍藏版)》请在冰点文库上搜索。
用户界面中的菜单至少应包括“选择菜单”、“输入X区间”、“开始绘制”、“退出”4项。
代码应适当缩进,并给出必要的注释,以增强程序的可读性。
2.课程设计说明书:
课程结束后,上交课程设计说明书和源程序。
课程设计说明书的格式和内容参见提供的模板。
四、指导教师和学生签字
指导教师:
________
学生签名:
刘峰________
五、成绩:
六、教师评语:
目录
(一).程序设计题目2
(二).题目分析2
(三).总体设计3
(四).模块设计4
(五).关键技术分析4
(六).完整的源程序6
(七).总结:
8
一·
程序设计题目:
绘制函数曲线。
二·
题目分析:
(一).经过对程序设计题目的分析可知,整个程序的设计实现大致分为:
绘制坐标.绘制图形。
在绘制坐标中,关键步骤是将笛卡儿坐标转化成屏幕坐标。
(二).需求分析:
(1).首先要选择显示器适配器,由于不知道是什么类型的适配器,所以用自动检测显示器适配器类型。
将相应的驱动器程序装入,并将其最高的显示模式作为当前的显示模式。
(2).画图前一般要清除屏幕因,因而必须使用清屏函数。
(3).为了简化运算,故而采用图示口设置函数:
既在图形方式下可以在屏幕上某一区域设置一个窗口。
这样秒以后的画图均在这个窗口内进行,且适用的坐标则以此窗口左边顶上角为(0,0)点作参考而不再用屏幕物理坐标(物理坐标把显示屏左上角定为(0,0)点)。
在图示口内可将画的图形显示出来每超出图示口的不分可以不显示(剪断),也可以显示(不减断)。
(4).画出坐标轴。
在屏幕上画图时,同在纸上画图一样。
在纸上画线,画笔要放在开始画图的位置,并经常要抬笔移动满意边到另一位置再做画图动作。
在屏上画图时也可想象有一无形的画笔,可以控制它的定位.移动(不画).可知道它能移动的最大位置限定等。
.
三·
总体设计:
四·
模块设计
fun3
Intgrophdriver=DETECT,graphmode
initgraph(&
graphdriver,&
graphmode,"
"
)
Voidfarcleardevice
Voidfarsetviewport(int10,int10,int610,int430,clipflag1)
绘制坐标
x1=max_x/2+xmin*coe_x,y1=max_y/2-(a*xmin*coe_x*xmin*coe_x+b*xmin*coe_x+c)*coe_y
moveto((int)x1,(int)y1)
for(x=xmin*coe_x;
x<
=xmax*coe_x;
x++)
x2=max_x/2+x,y2=max_y/2-(a*x*x+b*x+c)*coe_y;
lineto((int)x2,(int)y2);
图2
五·
关键技术分析
1.显示器设定:
intgraphdriver=DETECT,graphmode
2.图形初始化:
3.图示口设置:
voidfarsetviewport(int10,int10,int600,int600,clipflag1);
setbkcolor(blue);
setcolor(yellow);
4.绘制坐标轴:
voidfarline(int0,int210,int600,int210,colorwrite);
voidfarline(int300,int0,int300,int420,colorwrite);
outtextxy(290,220,"
(0,0)"
);
outtextxy(590,220,"
x"
uttextxy(290,10,"
y"
5.坐标之间的转换:
x1=max_x/2+xmin*coe_x,y1=max_y/2-(a*xmin*coe_x*xmin*coe_x+b*xmin*coe_x+c)*coe_y;
moveto((int)x1,(int)y1);
for(x=xmin*coe_x;
{
x2=max_x/2+x,y2=max_y/2-(a*x*x+b*x+c)*coe_y;
lineto((int)x2,(int)y2)
}
6.目录选择功能:
switch(n)
case1:
fun1();
break;
case2:
fun2();
case3:
fun3();
case4:
exit(0);
default:
printf("
\nerror\n"
图3数据的输入
六·
完整的源程序
#include<
stdio.h>
graphics.h>
floata,b,c,xmin,xmax,max;
voidmenu()
{
\n************************************HELL0***********\n"
\n1.inputcoefficient"
\n2.inputextent"
\n3.drawfunctioncurve"
\n4.quit"
\n**********************************************************\n"
fun1()
printf("
inputa,b,c\n"
scanf("
%f,%f,%f"
&
a,&
b,&
c);
fun2()
inputxmin,xmax\n"
%f,%f"
xmin,&
xmax);
funmax()
floatp,q;
if(xmin<
0)
p=-xmin;
else
p=xmin;
if(xmax<
q=-xmax;
q=xmax;
if(p>
=q)
max=p;
max=q;
floatfunx(floatmax_x),maxx=600
return(max_x/2/max);
floatfuny(floatmax_y),mayy=420
floatt;
t=max_y/2/(a*max*max+b*max+c);
return(t);
fun3()
intmax_x=600,max_y=420;
intgraphdriver=DETECT,graphmode;
floatx1,y1,x2,y2,x,y,coe_x,coe_y;
initgraph(&
cleardevice();
voidfarsetviewport(int10,int10,int600,int600,clipflag1);
coe_x=funx(max_x);
coe_y=funy(max_y);
voidfarline(int20,int210,int580,int210,colorwrite);
voidfarline(int20,int300,int400,int300,colorwrite);
outtextxy(590,220,"
outtextxy(290,10,"
x1=max_x/2+xmin*coe_x,
y1=max_y/2-(a*xmin*coe_x*xmin*coe_x+b*xmin*coe_x+c)*coe_y;
moveto(intx1,inty1);
}
getch();
closegraph();
}
main()
intk;
menu();
while
(1)
%d"
k);
switch(k)
{
case1:
fun1();
case2:
}
总结:
这次课程设计,加强了我对c语言的了解。
对一些细节的掌握更加深刻,而且对一些没有学过的内容通过查阅课外书也学会了,即增加了知识也加强了自己动脑动手的能力。
同时也从中体会到了那种经过努力而得到成功的喜悦,也对我以后工作学习带来了信心和帮助,从而更加坚定了我对以后探索知识的信念,尽量的去摄取更多的更深的知识,做一个合格的人
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 绘制 函数 曲线