?? main.cpp
字號:
#include "BinTree.cpp"
/*1、實(shí)現(xiàn)二叉樹輸出功能。按照第二題中的凹入表結(jié)構(gòu)表達(dá)。
2、 實(shí)現(xiàn)一個(gè)判斷兩個(gè)二叉樹是否相等的接口(最好操作符重載)
3、 讀取一個(gè)二叉樹的前序和中序遍歷結(jié)果,恢復(fù)這個(gè)二叉樹(即實(shí)現(xiàn)其鏈?zhǔn)降拇鎯Γ?4、 對于鏈?zhǔn)降亩鏄洌磳哟伪闅v二叉樹*/
int main()
{//主函數(shù)
BinaryTree <int> tree(0),tree1(0);
cout<<" Construct BinaryTree tree :\n ";
cout<<" Input data(end with "<<tree.GetRefValue()<<"):\n";
cin >> tree;
cout<<"\n\n\n >********************************************<\n tree凹入表輸出:\n";
int i = 0 ;
tree1.Print ( tree.GetRoot() , i );//凹入表輸出
cout<<"\n\n tree前序遍歷 :";
tree.Traverse1(tree.GetRoot());
cout<<"\n tree層次遍歷 :";
tree.LevelOrder( tree.GetRoot() );//層次輸出
cout<<endl;
ofstream fout;
fout.open("datafile.txt",ios::binary|ios::out);
if ( !fout ) { cerr<<" The datafile cannot be opened!\n";}
fout << tree;//前序、中序遍歷輸出到文件
fout.close();
cout<<"Reconstruct the tree ,\nacorrding to the Preorder Traversal and the Inorder Traversal\n";
ReConstruct (tree);//構(gòu)造一棵新樹newtree,并判斷是否相等,輸出構(gòu)造是否成功信息。
cout<<endl;
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -