#include "tree.h" #include #include int main() { Tree tree { }; std::ifstream ifs { "values.txt" }; int value { }; while (ifs >> value) { if (not tree.contains(value)) tree.insert(value); } std::string command { }; while (true) { std::cout << "> "; if (not (std::cin >> command)) break; std::vector values { }; if (command == "exit") break; else if (command == "print") tree.print(std::cout); else if (command == "inorder") values = tree.inorder(); else if (command == "postorder") values = tree.postorder(); else if (command == "preorder") values = tree.preorder(); else { std::cout << "Unknown command '" << command << "'" << std::endl; continue; } for (int value : values) std::cout << value << " "; std::cout << std::endl; } }