#include <iostream> #include <vector> #include<map> using namespace std; struct tree { struct tree* l=nullptr; struct tree* r=nullptr; char val='\0'; }; string input; int index=0; void build(tree*& root) { if (input[index] == '#') { index++; return; } else { root=new tree(); root->val = input[index]; index++; build(root->l); build(root->r); } } void mid(tree* r) { if (r == nullptr) { return; } mid(r->l); cout << r->val << ' '; mid(r->r); } int main() { tree* root; cin >> input; build(root); mid(root); return 0; }