#include <iostream>
#include <queue>
using namespace std;
typedef struct Tree
{
char data;
Tree* lchild, * rchild;
}T;
void Tree_creat(T*& root)
{
char data;
cin >> data;
if (data != '#')
{
root = new T;
root->data = data;
Tree_creat(root->lchild);
Tree_creat(root->rchild);
}
else
{
root = nullptr;
}
}
void sequence_order(T* root)
{
if (root == nullptr)return;
queue<T*> q;
q.push(root);
while (!q.empty())
{
T* front = q.front();
q.pop();
cout << front->data;
if (front->lchild)q.push(front->lchild);
if (front->rchild)q.push(front->rchild);
}
}
int main()
{
T* root = nullptr;
Tree_creat(root);
sequence_order(root);
return 0;
}
06-27
1143

05-06
1109
