koch 雪花的非递规 实现
2005-6-27 8:27:27 来源:本站整理 作者:不详 【大 中 小】 投递文章
内容提要:/*程序实现的算法:用链表来存储边的信息用边的数量来判断边的方位。*/#include<stdio.h>#include<math.h>#include<conio.h>#include<stdlib...
/* 程序实现的算法: 用链表来存储边的信息
用 边的数量来判断 边的方位。
*/
#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();