#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
/*对二叉树的基本理解,简单题*/
/*其实这东西网上教程很多,二叉树的遍历和二叉树建立的写法差不多*/
char str[101];
int x;
/*注意这里 要*tree ,之前没有* 错了没发现。。。*/
typedef struct node{
char c;
struct node *lchild, *rchild;
}TNode, *Tree;
void Creat(Tree &T){
if(str[x] == '#'){
x++;
T = NULL;
return;
}
T = (TNode*)malloc(sizeof(TNode));//一定要开辟内存空间
T->c = str[x++];
T->lchild = NULL;
T->rchild = NULL;
Creat(T->lchild);
Creat(T->rchild);
return;
}
void print(Tree T){
if(T == NULL)
return;
print(T->lchild);
printf("%c ", T->c);
print(T->rchild);
}
int main(){
while(gets(str)){
x = 0;
Tree T;
//T = Creat();
Creat(T);
print(T);
printf("\n");
}
return 0;
}