?? btree.cpp
字號:
/*二叉樹操作--源代碼及關(guān)鍵源代碼注解如下:*/
#include<iostream.h>
#include<fstream.h>
#include"RBtree.h"
int main()
{
ifstream data("BTREE.txt", ios::in|ios::nocreate);
if(data.bad())
{
cout<<endl<<"file not found"<<endl;
return 1;
}
int choice,num;
RBtree<int> tr;
data>>choice;
while(!data.eof())
{
if(choice<6) // the func 6 to 8 don't need arguments
data>>num;
switch(choice)
{
case(1):cout<<"Insert - "<<num<<endl;
tr.Insert(num);
break;
case(2):cout<<"Delete - "<<num<<endl;
tr.Delete(num);
break;
case(3):cout<<"Find - "<<num<<endl;
if(tr.Find(num))
cout<<num<<" exist in tree"<<endl;
else
cout<<num<<" doesn't exist in tree"<<endl;
break;
case(4):cout<<"the successor of "<<num<<" is:"<<endl;
cout<<tr.Succ(num);
cout<<endl;
break;
case(5):cout<<"the predecessor of "<<num<<" is:"<<endl;
cout<<tr.Pred(num);
cout<<endl;
break;
case(6):cout<<"the min value of the tree is: ";
cout<<tr.Min(num);
cout<<endl;
break;
case(7):cout<<"the max value of the tree is: ";
cout<<tr.Max(num);
cout<<endl;
break;
case(8):cout<<"printing tree"<<endl;
tr.Print();
break;
default:cout<<endl<<"the choice number is out of range"<<endl;
break;
}
data>>choice;
}
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -