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


C++ BST::Print方法代码示例

本文整理汇总了C++中BST::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ BST::Print方法的具体用法?C++ BST::Print怎么用?C++ BST::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BST的用法示例。


在下文中一共展示了BST::Print方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc,char **argv)
{
  // Create an empty Binary Search Tree
  BST Tree;
  string input = "";
  while (input !="ENDINSERT")
  {
     cin >> input;
     if (input != "ENDINSERT")
     	Tree.Insert(input);     
  }
  Tree.Print("POST");
}
开发者ID:Sudoka,项目名称:C_Plus_Plus_Examples,代码行数:13,代码来源:BSTinserting.cpp

示例2: main

int main(int argc,char **argv)
{
    // Create an empty Binary Search Tree
    BST Tree;
    string input;
    cin >> input;
    while(input != "ENDINSERT") {
        //cout << "got here" << endl;
        Tree.Insert(input);
        cin >> input;
    }
    //cout << "done inserting" << endl;
    Tree.Print("POST");
}
开发者ID:Sudoka,项目名称:algorithms,代码行数:14,代码来源:BSTinserting.cpp

示例3: main

void main() // key(pair사용시 data.first) = 노드의 이름 같은 개념,  element(pair 사용시 data.second)  = 노드의 고유 data
{
	//declare the type of K, E
	typedef  int K;
	typedef char E;
	BST<K, E> HWbst;	// Making BST class HWbst  link every nodes

	int menu = 0;
	while (1)
	{
		//   Menu   //
		cout << endl << " #### Choose Menu ####" << endl;
		cout << "1. Insert      2. Delete      3. Print      4. Exit" << endl;
		cin >> menu;
		switch (menu)
		{
			case 1: // Insert Menu
			{
					  
					  pair<K, E> A;  // new node's pair type data
					  cout << " *** 새로운 TreeNode의 Key : ";
					  cin >> A.first;
					  cout << " *** 새로운 TreeNode의 Element : ";
					  cin >> A.second;

					  HWbst.Insert(A); // use insert function
					  break;
					  
			}
			case 2: // Delete Menu
			{	
					  int a = 0;
					  cout << " *** 삭제할 노드의 Key 입력  :  ";
					  cin >> a;
					  HWbst.Delete(a);
					  break;
			}
			case 3: // Print all nodes by level order
			{
					  HWbst.Print();
					  break;
			}
			case 4:  // close this program
			{
					  return;
			}
		}
	}
	
}
开发者ID:jaeen1113,项目名称:HW_Project,代码行数:50,代码来源:main.cpp

示例4: main

int main(int argc,char **argv)
{
  // Create an empty Binary Search Tree
  BST Tree;
  //Tree=new BST();
  string input;
  cin>>input;
  while(input!="ENDINSERT"){
	Tree.Insert(input);
	
	cin>>input;
  }
  Tree.Print("POST");
}
开发者ID:vjain05,项目名称:CSE100labs,代码行数:14,代码来源:BSTinserting.cpp

示例5: main

int main(int argc,char **argv)
{
  // Create an empty Binary Search Tree
  BST Tree;
  string input;
  cin>>input;
  while(input!="ENDINSERT"){
	Tree.Insert(input);
	
	cin>>input;
  }
  //Tree.Print("POST");
  //cout<<"transition"<<endl;
  cin>>input;
  while(input!="ENDDELETE"){
		Tree.Delete(input);
	  cin>>input;
  }
  Tree.Print("POST");
}
开发者ID:vjain05,项目名称:CSE100labs,代码行数:20,代码来源:BSTdeleting.cpp

示例6: main


//.........这里部分代码省略.........
					{
						bst.DeleteItem(input);
						cout << endl << input << " is removed!" << endl << endl;
					}
					catch(NotFound)
					{
						cout << endl << "Number was not found!" << endl << endl;
					}
				}
				else
				{
					cout << "What is the string you would like to remove?" << endl;
					cin.ignore();
					getline(cin, temp);
					input = (char*)temp.c_str();
					try
					{
						bst.DeleteItem(input);
						cout << endl << input << " is removed!" << endl << endl;
					}
					catch(NotFound)
					{
						cout << endl << "String was not found!" << endl << endl;
					}
				}

				command = 'M';
			}
			else if (command == 'D' || command == 'd')
			{
				if (!bst.IsEmpty())
				{
					cout << endl << "Displaying..." << endl;
					bst.Print(cout);
					cout << endl << endl;
				
					bool finished = false;
					bst.ResetTree(IN_ORDER);
					cout << "InOrder: ";
					while(!finished)
						cout << bst.GetNextItem(IN_ORDER, finished) << " ";
				
					finished = false;
					bst.ResetTree(PRE_ORDER);
					cout << endl << "PreOrder: ";
					while(!finished)
						cout << bst.GetNextItem(PRE_ORDER, finished) << " ";
				
					finished = false;
					bst.ResetTree(POST_ORDER);
					cout << endl << "PostOrder: ";
					while(!finished)
						cout << bst.GetNextItem(POST_ORDER, finished) << " ";

					cout << endl << endl;
				}
				else
					cout << "The tree is empty!" << endl << endl;

				command = 'M';
			}
			else if (command == 'C' || command == 'c')
			{
				cout << endl << "Chopping...Timber!" << endl;
				bst.MakeEmpty();
				cout << "Tree is empty!" << endl << endl;
开发者ID:Gillium,项目名称:cs218,代码行数:67,代码来源:bstDriver.cpp


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