本文整理汇总了C++中Tree::Inorder方法的典型用法代码示例。如果您正苦于以下问题:C++ Tree::Inorder方法的具体用法?C++ Tree::Inorder怎么用?C++ Tree::Inorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::Inorder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
Tree t;
int ch=0,x;
while(ch!=6)
{
cout<<"\n\n----Tree----\n";
cout<<"\n1.Inorder";
cout<<"\n2.Preorder";
cout<<"\n3.Postorder";
cout<<"\n4.Insert";
cout<<"\n5.Delete";
cout<<"\n6.Exit";
cout<<"\nEnter the choice :";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\nInorder : ";
t.Inorder();
break;
case 2:
cout<<"\nPreorder :";
t.Preorder();
break;
case 3:
cout<<"\nPostorder:";
t.Postorder();
break;
case 4:
cout<<"\nEnter the data:";
cin>>x;
t.Insert(x);
break;
case 5:
cout<<"\nEnter the data:";
cin>>x;
t.Delete(x);
break;
}
}
}
示例2: main
// Test main program
int main() {
Tree* tree = new Tree();
char data;
int choice;
while(1)
{
cout<<"1> Add Node\n2> Pre order traversal\n3> In order traversal\n4>Post order traversal\n5> Exit\nCHOOSE WISELY::";
cin>>choice;
switch(choice)
{
case 1:
cout<<"\nEnter data:";
cin>>data;
tree->addNode(data);
break;
case 2:
cout << "Pre order traversal" << endl;
tree->Preorder(tree->Root());
cout << endl;
break;
case 3:
cout << "In order traversal" << endl;
tree->Inorder(tree->Root());
cout << endl;
break;
case 4:
cout << "Post order traversal" << endl;
tree->Postorder(tree->Root());
cout << endl;
break;
case 5:
exit(0);
}
}
delete tree;
return 0;
}
示例3: main
void main()
{
Tree t;
int data,iChoice=0;
while(iChoice!=5)
{
cout<<"\n\t\t1.Insert";
cout<<"\n\t\t2.Inorder";
cout<<"\n\t\t3.Preorder";
cout<<"\n\t\t4.Postorder";
cout<<"\n\t\t5.Exit";
cout<<"\nEnter your choice";
cin>>iChoice;
switch(iChoice)
{
case 1:
cout<<"\nEnter data to push";
cin>>data;
t.Insert(data);
break;
case 2:
t.Inorder();
break;
case 3:
t.Preorder();
break;
case 4:
t.Postorder();
break;
case 5:
break;
default:
cout<<"\nInvalid choice";
}
}
}