#include<iostream>
using namespace std;
typedef class node {
friend class tree;
private:
node* left;
node* right;
int val;
public:
node(int v)
{
val = v;
left = NULL;
right = NULL;
}
~node() {};
}*t;
class tree {
private:
t root;
public:
tree()
{
}
tree(const t &r)
{
root = r;
}
~tree()
{
;
}
void CreateTree(node *&r)
{
int ch;
cin >> ch;
if (ch==-1)
{
r = NULL;
}
else
{
r = new node(ch);
CreateTree(r->left);
CreateTree(r->right);
}
}
node* Root()
{
return root;
}
void PreOrder(node* &r)
{
if (r)
{
cout << r->val;
PreOrder(r->left);
PreOrder(r->right);
}
}
};
int main()
{
node *n;
tree tt(n);
tt.CreateTree(n);
tt.PreOrder(n);
return 0;
}
answer is below