69,374
社区成员
发帖
与我相关
我的任务
分享
typedef char TelmType;
typedef struct node //定义一个结构体
{
TelmType date; //都是错别字
struct node *lc,*rc;
}Bitree; //这里少;
Bitree *create_bt()
{
Bitree *root =(Bitree *)malloc(sizeof(Bitree)); //分配存储空间
Bitree *p,*s[20]; //s[i]应该是指针,照你后面的用法
TelmType x;
int i,j;
printf("i,x");
scanf("%d,%c",&i,&x);
while(i!=0&&x!='#')
{
p=(Bitree *)malloc(sizeof(Bitree));
p->date=x; //p=data=x;全是错别字
p->lc=NULL;
p->rc=NULL;
s[i]=p; //p是指针
if(i==1)
{
root=p;
}
else
{
j=i/2;
if(i%2==0)
s[j]->lc=p;
else s[j]->rc=p;
printf("i,x");
scanf("%d,%c",&i,&x);
}
}
return root;
}
void main()
{
Bitree *bt;
bt=create_bt();
}