📄 btree.cpp.bak
字号:
/*第4题 二叉树操作--源代码及关键源代码注解如下:*/
// By Dror Helper. last updated 23.1.2002
#include<iostream.h> // Dror Helper I.D. 034354712
#include<fstream.h> // sample main for RB tree
#include"RBtree.h"
int main()
{
ifstream data("data4.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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -