Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  C语言  >  正文 koch 雪花的非递规 实现

koch 雪花的非递规 实现

发布时间:2018-12-16   编辑:www.jquerycn.cn
jquery中文网为您提供koch 雪花的非递规 实现等资源,欢迎您收藏本站,我们将为您提供最新的koch 雪花的非递规 实现资源

/* 程序实现的算法: 用链表来存储边的信息

  用 边的数量来判断 边的方位。

 */

 #include <stdio.h>
 #include <math.h>
 #include <conio.h>
 #include <stdlib.h>
 #include <graphics.h>

 #define  Left  0   //  方向常量
 #define  Right  1
 #define  Bottem  2

 #define fcolor   1
 #define bkcolor   0
 #define N   10
 #define PD   M_PI/180

 typedef struct Point//  定义节点
     {
     float x;
     float y;
     }Point;
 typedef struct Elegs//  定义边
     {
     Point a;
     Point b;
     struct Elegs *next;
     }Elegs;

 
 Elegs *head;
 int n = 0 , Trend;//  Trend 方向性 指示变量, n为边的总数

 /*函数说明*/

 void Init();
 void Init_draw(int x,int y,int len ,int du);//  初始化 画三角形
 void Draw(Point a,Point b,int du , int bool);//  具体实现画边
 void Check_trand(int i); //  检测边的方向性
 void show(Elegs *head,int du);//  链表用以动态存储 边的信息
 void End();

 Elegs *New();
 Elegs *Add(Elegs *head,Point a,Point b);
 Elegs *freelink(Elegs *head);

void Init()
 {
  int gd=DETECT,gm,ec;
  Elegs *p;

  initgraph(&gd,&gm,"d:\tc3\bgi");
  ec = graphresult();
  if(ec !=grOk)
 {
 printf("The graphic error:");
 printf("%s ",grapherrormsg(ec));
 printf("Key any to halt:");
 getch();
 exit(0);
 }
  setbkcolor(bkcolor);
  setcolor(fcolor);
  Trend = 0;

  p = New();
  head = p;
  p->next = NULL;
  };//  Init

 void Init_draw (int x,int y,int len, int du)
 {
  int x1,x2,y1,y2;
  Point a,b,c;
  Elegs *p;

  x1 = x - len* cos((60 du)*M_PI/180);
  y1 = y len* sin((60 du)*M_PI/180);

您可能感兴趣的文章:
如何使用HTML5 canvas实现雪花飘落
koch 雪花的非递规 实现
圣诞节Merry Christmas给博客添加浪漫的下雪效果基于jquery实现
让你的博客飘雪花超出屏幕依然看得见
用canvas实现简单的下雪效果(附代码)
想系统学习GO语言(Golang
Photoshop设计逼真漂亮雪景制作教程
PHP发送POST请求的常用方式
利用SurfaceView实现下雨与下雪动画的效果
html5如何使用canvas画空心圆与实心圆

[关闭]