?? exam.cpp
字號:
#include"exam5.h"
void main()
{
Tree<char> t;int choice=0;
while(true)
{
system("cls");
cout<<" 樹和森林實驗\n";
cout<<" 1.將一棵樹(或森林)轉換為二叉樹 2.求森林的高度\n";
cout<<" 3.按層次方式遍歷森林 4.輸出一個森林的廣義表形式\n";
cout<<" 5.輸出一個森林中每個結點的值及其對應的層次數 0.退出\n";
cout<<"請輸入選擇項目:";cin>>choice;
if(choice==0)break;
if(choice==1)
{
system("cls");
BT<char> b;t.filecreat(t.root);
t.trans(t.root,b.root);cout<<"轉換為二叉樹后中序遍歷:"<<endl;
b.inOrder(b.root);cout<<endl;
system("pause");continue;
}
if(choice==2)
{
system("cls");
t.filecreat(t.root);
cout<<"此樹高度為:";
cout<<t.height(t.root)<<endl;
system("pause");continue;
}
if(choice==3)
{
system("cls");
t.filecreat(t.root);
cout<<"層次遍歷為:"<<endl;
t.display1(t.root);cout<<endl;
system("pause");continue;
}
if(choice==4)
{
system("cls");
t.filecreat(t.root);
cout<<"廣義表形式為:"<<endl;
t.show(t.root);
system("pause");continue;
}
if(choice==5)
{
system("cls");
t.filecreat(t.root);
t.display2(t.root,1);cout<<endl;
system("pause");continue;
}
else
{
cout<<"選擇無效!"<<endl;system("pause");continue;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -