二叉树
绘图库:Easy Graphics Engine (EGE)
编程语言:c++
二叉树
夹角:90度
夹角:120度
夹角:180度
夹角:60度
代码:
#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <time.h>
const double pi = 3.1415926536;
struct Point
{
double x;
double y;
};
void draw(double x,double y,double A,double l,int n,double t,double u)
{
double x1,y1,L,R;
if(n>0)
{
x1=x+cos(A)*l;
y1=y+sin(A)*l;
line_f(x,y,x1,y1);
L=A+t;
R=A-t;
l=l*u;
draw(x1,y1,L,l,n-1,t,u);
draw(x1,y1,R,l,n-1,t,u);
}
}
int main()
{
int n=15;
printf(" 二叉树\n");
printf("\n\n");
initgraph(600,600);
setcolor(RED);
draw(300,0,pi/2,200,n,pi/2,0.58);
getch();
closegraph();
return 0;
}