c语言绘制二叉树

树如下:
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分

你那里是打印出的啥?不会是没有存下数据打印了乱码吧?:)

[修改]
比如,我把和你的二叉树相关的代码去掉,改了一下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <graphics.h>

int main()
{
char str[10];
int x = 100, y = 100;
int e = 9;

/* select a driver and mode that supports */
/* multiple drawing colors. */
int gdriver = DETECT, gmode = VGA, errorcode;

detectgraph(&gdriver, &gmode);
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "d:\\bc\\bgi");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(x,y,9,9);
setcolor(WHITE);
circle(x,y,10);

sprintf(str,"%d",e);
outtextxy(x-3,y-2,str);

/* clean up */
getch();
/* colse */
closegraph();

return 0;
}
就能在圈圈里打印出"9"
温馨提示:答案为网友推荐,仅供参考