#include using namespace std; //--------------------------------------------------------------------- class link1 { private: int element; link1 *left, *right; public: link1(int val)//constructer { right=NULL; left=NULL; element=val; }; ~link1()//destructer { if (right) delete right; if (left) delete left; }; void Add(int v)//adding element { if (vAdd(v); else left=new link1(v); } else { if (right) right->Add(v); else right=new link1(v); } }; void Print_elem()//printing element { if (left) left->Print_elem(); cout<Print_elem(); }; }; //--------------------------------------------------------------------- class Tree { private: link1 *root; public: Tree() {root=NULL;}//constructer ~Tree() {delete root;}//destructer void Print_all()//printing tree { root->Print_elem(); cout<<"\n"; }; void AddEl(int i)//adding element to tree { if (!root) { root=new link1(i); } else root->Add(i); }; }; //--------------------------------------------------------------------- int main(void) { Tree *T; int l; T= new Tree(); while (l>=0) { cin>>l; T->AddEl(l); } T->Print_all(); delete T; return 0; }