Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. template<typename T>
  2. void Tree<T>::CreateTree(int i, int parentIndex)
  3. {
  4. if (i >= size)
  5. {
  6. return;
  7. }
  8.  
  9. Node<T> el;
  10. T x; char ch;
  11. std::cout << "root: " << i << " " << std::endl;
  12. std::cin >> x;
  13. el.root = x;
  14. el.position = parentIndex;
  15. p[i] = el;
  16.  
  17. std::cout << "left BinTree of: " << x << " y/n? ";
  18. std::cin >> ch;
  19. if (ch == 'y')
  20. {
  21. CreateTree(2 * i + 1, i);
  22. }
  23.  
  24. std::cout << "right BinTree of: " << x << " y/n? ";
  25. std::cin >> ch;
  26. if (ch == 'y')
  27. {
  28. CreateTree(2 * i + 2, i);
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement