树如下:
typedef struct Tree/*二叉树*/
{
int e;
int type;
struct Tree * lchild;
struct Tree * rchild;
struct Tree * parents;
int x;/*横坐标*/
int y;/*纵坐标*/
}tree;
绘制函数如下:
void DrawTree(tree *t)
{
if(t!=NULL)
{
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(t->x,t->y,9,9);
setcolor(WHITE);
circle(t->x,t->y,10); /*画圆*/
sprintf(str,"%d",t->e);/*将内容转换成字符串输出*/
outtextxy(t->x-3,t->y-2,str);
if(t->lchild!=NULL)/*左子树*/
{
line(t->x-5,t->y+12,t->lchild->x+5,t->lchild->y-12);
DrawTree(t->lchild);
}
if(t->rchild!=NULL)/*右子树*/
{
line(t->x+5,t->y+12,t->rchild->x-5,t->rchild->y-12);
DrawTree(t->rchild);
}
}
}
绘制后 圆内无法显示相应节点的数据,那位高手帮忙指点一下,不胜感激!
另有生成树的一个结点图片
问题解决后会有追加积分至少50分