当前位置: 首页>>代码示例>>C++>>正文


C++ Tree::Inorder方法代码示例

本文整理汇总了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;
		}
	}
	
	

}
开发者ID:prijuly2000,项目名称:Data-Structure,代码行数:46,代码来源:main.cpp

示例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;
} 
开发者ID:joyjitc,项目名称:lab,代码行数:41,代码来源:tree.cpp

示例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";
		}
	}
}
开发者ID:prijuly2000,项目名称:Data-Structure,代码行数:36,代码来源:main.cpp


注:本文中的Tree::Inorder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。