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


C++ BinaryTree::in_order方法代码示例

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


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

示例1: main

int main(){

	char anyKey;
	cout<<"Arboles Binarios"<<endl;

	BinaryTree<TreeTraits> btMyTree;
	
	btMyTree.insert(33);
	btMyTree.insert(23);
	btMyTree.insert(41);
	btMyTree.insert(11);
	btMyTree.insert(27);
	btMyTree.insert(37);
	btMyTree.insert(51);
	
	cout<<"InOrder"<<endl;
	btMyTree.in_order(btMyTree.root);
	cout<<"PreOrder"<<endl;
	btMyTree.pre_order(btMyTree.root);
	cout<<"PostOrder"<<endl;
	btMyTree.post_order(btMyTree.root);

	cout<<"Wait any key ..."<<endl;
	cin>>anyKey;
	return 0;
};
开发者ID:dorisserruto,项目名称:cplus2basic,代码行数:26,代码来源:main.cpp

示例2: main

int main()
{
    BinaryTree<char> t;
    Node<char> *a = t.makeTree('A', NULL, NULL);
    Node<char> *b = t.makeTree('B', NULL, NULL);
    Node<char> *c = t.makeTree('C', a, b);
    Node<char> *d = t.makeTree('D', NULL, NULL);
    Node<char> *e = t.makeTree('E', c, d);
    Node<char> *f = t.makeTree('F', NULL, e);

    t.pre_order();
    cout << endl;
    t.in_order();
    cout << endl;
    t.post_order();
    cout << endl;
    cout << t.get_nodenum() << endl;
    cout << t.get_height() << endl;
    return 0;
}
开发者ID:yixiaoming,项目名称:Algorithm,代码行数:20,代码来源:main.cpp

示例3: main

/* usage:  ./proj5 organisms.txt
 * *******************************************
 * Given a correct file the program takes a list of organisms and
 * constructs its ancestral tree based on the scores in the file.
 * The only output is the string parenthetical expression which
 * represents the closest organisms joined in a tuple of the form
 * ((dog,wolf),mountianGoat)
 *
 */
int main(int argc, char* argv[]){
	std::string addressFile="";
	/*
	 * If the program is ran without sufficient arguments it Will exit gracefully
	 * with suggestions for the usage of the program.
	 */
	if (argc < 2) {
		std::cerr << "Address File not Found\n";
		std::cerr << "Usage:  " << argv[0] << " adresses.txt" << std::endl;
		return -1;
	}

	addressFile=argv[1];
	std::ifstream inFile;
	inFile.open(addressFile.c_str()); // need to open the fileargv[1].c_str()

	if(!inFile){
		write_Log( "Valid File not found:  ** Exiting ** ");
		exit(1);
	}


	std::list< BinaryTree<Organism*> *> treeList;
	/****************************************
	 * Build a vector of Organisms from the file
	 ***********************************************/
	try {
		std::string str;
		std::vector<std::string> data;
		while(std::getline(inFile, str, '\n'))	{

			try{
				 data = split(str);
			}catch(...){
			    	write_Log("**********Exception Throw splitting string:  Line Skipped********");
			    	write_Log("Error Occured IN: "+str);
			    	continue;
			}
			//double score = std::stod (data[1]);
			Organism * toAdd = new Organism(data[0], atoi(data[1].c_str()));
			//Organism * toAdd = new Organism(data[0], score);
			BinaryTree<Organism*> * tree = new BinaryTree<Organism*> (toAdd);
			treeList.push_front(tree);
		}
	} catch(...){
		write_Log( "*********Exception thrown building Binary Trees: *********");
		write_Log("*********Please correct Invalid Input: ********************");
	}
	/********************************************
	 *Initial List of Binary Trees Built
	 *******************************************/
	//write_Log("Length of list of trees =  "+convertDigit(treeList.size()));

	/*******************************************************************
	 * Build LifeTree:
	 * *****************************************************************
	 */
	BinaryTree<Organism*> orgTree;
	buildOrgTree(treeList,orgTree);

	/*
	 *DISPLAY THE FINAL TREES ROOT NODE
	 */
	orgTree.in_order(display);
	write_Log("orgTree has heigh = " + convertDigit(orgTree.height()));
	write_Log(orgTree.get_root()->toString());
	return 0;
}
开发者ID:n-critser,项目名称:cuny-cpp,代码行数:77,代码来源:main.cpp


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