#include <iostream> #include <math.h> #include<bits/stdc++.h> using namespace std; string str; int pos; struct Tnode { char val; Tnode* left; Tnode* right; Tnode(char c): val(c), left(NULL), right(NULL) {}; }; Tnode* creatTree() { char c = str[pos++]; if (c == '#')return NULL; Tnode* root = new Tnode(c); root->left = creatTree(); root->right = creatTree(); return root; } void Inoder(Tnode* root) { if (root == NULL)return; Inoder(root->left); cout << root->val << ' '; Inoder(root->right); } int main() { while (cin >> str) { pos = 0; Tnode* root = creatTree(); Inoder(root); cout << endl; } return 0; }