当前位置:首页 ›› 分形几何 ›› 分形几何 ›› 题目:Koch曲线C程序
【 注册 | 登陆 】
-
题目:Koch曲线C程序
- 作者:佚名
- 发表日期:十月 02, 2007
- 浏览:307次
-
收藏本文
- 编者导读:#include "graphics.h" #include "math.h" float x=80,y=420; int th=0,L=6; float dtor=3.1415926/180; void koch(int n) { float d; d=L/3^n; if(n==0) { moveto(x,y); x+=d*cos(th*dtor); y-=d*sin(th*dtor); lineto(x,y); return; } koch(n-1); th+=60; koch(n-1); th-=120; koch(n-1); th+=60; koch(n-1); } main() { int 
#include "graphics.h"
#include "math.h"
float x=80,y=420;
int th=0,L=6;
float dtor=3.1415926/180;
void koch(int n)
{
float d;
d=L/3^n;
if(n==0)
{
moveto(x,y);
x+=d*cos(th*dtor);
y-=d*sin(th*dtor);
lineto(x,y);
return;
}
koch(n-1);
th+=60;
koch(n-1);
th-=120;
koch(n-1);
th+=60;
koch(n-1);
}
main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
cleardevice();
setbkcolor(0);
setcolor(9);
line(80,60,560,60);
getch();
moveto(80,240);
lineto(240,240);
lineto(320,100);
lineto(400,240);
lineto(560,240);
getch();
settextstyle(2,0,5);
outtextxy(40,50,"(a)");
outtextxy(40,230,"(b)");
outtextxy(40,410,"(c)");
koch(5);
getch();
closegraph();
cleardevice();
}
-
前一篇:题目:Julia集C程序下一篇:题目:分形图形学讲座
- 【引用地址】http://www.suanshu.net/list/5062.aspx
- 【关键字】题目:Koch曲线C程序
版权申明:非特殊申明,本站文章均系转载自互联网,如果侵犯了你的合法权益,请告知我们,我们会第一时间处理.
要点评这篇文章,请在下面留言
针对这篇文章的评论
- 不良评论请用报告管理员,以利管理员及时删除。
- 尊重网上道德,遵守中华人民共和国的各项有关法律法规。
- 承担一切因您的行为而直接或间接导致的民事或刑事法律责任。
- 本站评论管理人员有权保留或删除其管辖评论中的任意内容。
- 您在本站发表的作品,本站有权在网站内转载或引用。
- 参与本评论即表明您已经阅读并接受上述条款。