本文整理汇总了C++中BinaryTree::del方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryTree::del方法的具体用法?C++ BinaryTree::del怎么用?C++ BinaryTree::del使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree::del方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
BinaryTree tree;
string command;
vector<string> commands;
int N;
int i = 0;
int size;
cout << "N = ";
cin >> N;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
while (i < N && i >= 0)
{
cout << i + 1 << ">>";
getline(cin, command);
commands = split(command, ' ');
size = commands.size();
if (size == 0)
{
cout << "Incorrect command. Try again.\n";
i--;
}
else if (size == 2)
{
if (commands[0] == "add")
tree.add(stoi(commands[1]));
else
{
cout << "Incorrect command. Try again.\n";
i--;
}
}
else if (size == 1)
{
try
{
if (commands[0] == "del")
tree.del();
else if (commands[0] == "get")
cout << tree.get() << endl;
else if (commands[0] == "show")
{
tree.show();
cout << endl;
}
else
{
cout << "Incorrect command. Try again.\n";
i--;
}
}
catch (char* message)
{
cout << message << endl;
}
}
else
{
cout << "Incorrect command. Try again.\n";
i--;
}
i++;
}
system("pause");
return 0;
}