```写了2种方法 第一种是先写的~开辟一个数组P[],在从P[1]-P[N]分别开辟树状态空间 再按顺序链接

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int z,y,n,n1=0,m,w=1;
char a[50000];
struct xtree
{
char date;
struct xtree *l,*r;
}*shu,*p[50100];
void push(int m)
{
p[m]=(struct xtree*)malloc(sizeof(struct xtree));
}
void qian(struct xtree *x)
{
char h;
h=x->date;
printf(" %c",h);
if(x->l!=NULL)
qian(x->l);
if(x->r!=NULL)
qian(x->r);
}
void qian2(struct xtree *x)
{
x->date=a[w];
w++;
if(x->date!='#')
qian2(x->l);
if(x->date!='#')
qian2(x->r);
}
void zhong(struct xtree *x)
{
char h;
h=x->date;
if(x->l->date!='#'&&x->date!='#')
zhong(x->l);
if(h!='#')
printf("%c",h);
if(x->r->date!='#'&&x->date!='#')
zhong(x->r);
}
void hou(struct xtree *x)
{
char h;
h=x->date;
if(x->l->date!='#'&&x->date!='#')
hou(x->l);
if(x->r->date!='#'&&x->date!='#')
hou(x->r);
if(h!='#')
printf("%c",h);
}

int main()
{
int i,j,k,t;
int b,c,h;
while(scanf("%s",a)!=EOF)
{
h=strlen(a);
for(i=h;i>0;i--)
{
a[i]=a[i-1];
}
for(i=1;i<13000;i++)
{
push(i);
}
for(k=1;k<=5000;k++)
{
p[k]->l=p[k*2];
p[k]->r=p[k*2+1];
}
qian2(p[1]);
zhong(p[1]);
if(p[1]->date!='#')
printf(" ");
hou(p[1]);
if(p[1]->date!='#')
printf(" ");
k=1;
for(i=1;i<=h😉
{
if(p[k]->date!=-51)
{
if(p[k]->date!='#')
printf("%c",p[k]->date);
i++;
}
k++;
}
printf("\n");
w=1;
for(k=1;k<13000;k++)
free(p[k]);
}
return 0;
}```

#include<stdio.h> #include<stdlib.h> #include<string.h> int z,y,n,n1=0,m,w=1,l=0; char a[3000]; struct xtree { char date; struct xtree *l,*r; }*p; struct xtree *push() { xtree *q; char x; l++; if(a[l]!='\0'&&a[l]!='#') { x=a[l]; } else return NULL; q=(struct xtree*)malloc(sizeof(struct xtree)); q->date=a[l]; q->l=push(); q->r=push(); return q; } void qian(struct xtree *x) { char h; h=x->date; printf("%c",h); if(x->l!=NULL) qian(x->l); if(h!='#') if(x->r!=NULL) qian(x->r); } void zhong(struct xtree *x) { char h; h=x->date; if(x->l!=NULL) zhong(x->l); if(h!='#') printf("%c",h); if(x->r!=NULL) zhong(x->r); } void hou(struct xtree *x) { char h; h=x->date; if(x->l!=NULL) hou(x->l); if(h!='#') if(x->r!=NULL) hou(x->r); printf("%c",h); } int main() { int i,j,k,t; int b,c,h; while(scanf("%s",a)!=EOF) { h=strlen(a); for(i=h;i>0;i–) { a[i]=a[i-1]; } p=push(); if(p!=NULL) { zhong(p); printf(" "); } if(p!=NULL) { hou(p); printf(" "); } if(p!=NULL) qian(p); printf("\n"); w=1; l=0; } return 0; }