大会员可查看代码,点此开通大会员
#include<bits/stdc++.h>
using namespace std;
typedef struct node{
public:
char val;
node *left,*right;
}*tree;
string s;
void create(tree &t,string s,int& i){
if(i>=s.size() ){
t=NULL;
return;
}else{
char c=s[i++];
if(c=='#'){
t=NULL;
return;
}
t=new node;
t->val=c;
t->left=NULL;
t->right=NULL;
create(t->left,s,i);
create(t->right,s,i);
}
}
void mido(tree &t){
if(t!=NULL){
mido(t->left);
cout<<t->val<<" ";
mido(t->right);
}
}
int main()
{
string s;
while(cin>>s){
int i=0;
tree t;
create(t,s,i);
mido(t);
cout<<endl;
}
}