紧急~!求高人指点

来源:百度知道 编辑:UC知道 时间:2024/06/30 02:59:54
#include “stdio.h"
struct node
{ int data;
struct node *l;
struct node *r;
}; struct node *root;

creat(struct node *new)
{
char ch;
ch=getchar();
if((int)ch==0)
return NULL:
else
{ new=(struct node *)malloc(sizeof(struct node));
new->data=(int)ch;
creat(new->l);
creat(new->r);
}

}

main()
{
struct node *thisnode=NULL;
creat(thisnode);
}

为何我的程序结果不对!
求高人给我指点,谢谢~!
恩,为何我那个程序会没用呢?
能告诉我问题是什么原因吗?
谢谢~!

#include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node *l;
struct node *r;
};

creat(struct node * &new1)
{
int ch;
ch=getchar()-48;
if(ch==0)
return NULL;
else
{
new1=(struct node *)malloc(sizeof(struct node));
new1->data=ch;
creat(new1->l);
creat(new1->r);
}

}

int main()
{
struct node *thisnode=NULL;
creat(thisnode);
return 0;
}

递归创建2叉树吗?