本文整理汇总了C++中BinaryTree::InOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryTree::InOrder方法的具体用法?C++ BinaryTree::InOrder怎么用?C++ BinaryTree::InOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree::InOrder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char * argv[]) {
const int n=15;
int i,a[n]={10,5,15,8,3,18,13,12,14,16,20,1,4,6,9};
BinaryTree<int> btree;
btree.Creat(a,n);
cout<<"输入数据:"<<endl;
for(i=0;i<n;i++) cout<<a[i]<<'\t';
cout<<endl<<"中序:"<<endl;
btree.InOrder(); //中序遍历输出升序
cout<<endl<<"前序:"<<endl;
btree.PreOrder();
cout<<endl<<"后序:"<<endl;
btree.PostOrder();
cout<<endl<<"广度(queue):"<<endl;
btree.WidthOrder();
cout<<endl<<"先序(stack):"<<endl;
btree.StackOrder();
cout<<endl;
// int i;
// Queue<char> que; //构造一个空链队
// char str1[]="abcdefghijklmnop"; //17个元素,包括串结束符
// for(i=0;i<17;i++) que.EnQue(str1[i]);
// for(i=0;i<17;i++) cout<<que.DeQue(); //先进先出
// cout<<endl;
// if(que.IsEmpty()) cout<<"队空"<<endl;
return 0;
}
示例2: test1
void test1()
{
int pre[]={1,2,4,8,9,5,10,3,6,7};
int in[]={8,4,9,2,10,5,1,6,3,7};
int post[]={8,9,4,10,5,2,6,7,3,1};
BinaryTree<int> btree;
//btree.CreateWithPre(pre,in,sizeof(pre)/sizeof(pre[0]));
btree.CreateWithPost(post,in,sizeof(post)/sizeof(post[0]));
btree.PreOrder();
btree.InOrder();
btree.PostOrder();
btree.PreOrder_NR();
btree.InOrder_NR();
btree.PostOrder_NR();
btree.LevelOrder();
cout<<btree.Depth()<<endl;
btree.PrintEdge1();
}
示例3: main
int main() {
BinaryTree* tree = new BinaryTree();
tree->InsertNode("A");
tree->InsertNode("B");
tree->InsertNode("C");
tree->InsertNode("D");
tree->InsertNode("E");
tree->InsertNode("F");
tree->InsertNode("G");
tree->InsertNode("H");
tree->InsertNode("I");
tree->InsertNode("J");
tree->InsertNode("K");
tree->InsertNode("L");
cout << "Pre order traversal" << endl;
tree->PreOrder(tree->root);
cout << endl;
cout << "In order traversal" << endl;
tree->InOrder(tree->root);
cout << endl;
cout << "Post order traversal" << endl;
tree->PostOrder(tree->root);
cout << endl;
cin.get();
return 0;
}