<span style="font-size:18px;">#include<cstdio>
#include<stdlib.h>
#include<iostream>
using namespace std;
struct node
{
char data;
node *l,*r;
};
node *t=(node*)malloc(sizeof(node));
node* build()
{
char ch;
scanf("%c",&ch);
node *neww=(node*)malloc(sizeof(node));
if(ch!='#')
{
neww->data=ch;
neww->l=build();
neww->r=build();
}
return neww;
}
void print(node *now)
{
if(now==NULL) return;
cout<<now->data<<endl;
print(now->l);
print(now->r);
}
int main()
{
t=build();
print(t);
return 0;
}
</span>
二叉树
最新推荐文章于 2024-05-23 09:55:46 发布