📄 bst_main.cpp
字号:
#include "bst.h"
#include <fstream.h>
void visit(Record &x)
{ cout<<x; }
void main(void)
{ Search_tree<Record> b; int x;
ifstream inFile("BST.IN");
inFile>>x;
while(x!=-999)
{ b.insert(x); inFile>>x; } inFile.close();
cout<<"Binary_tree B Recursive PreOrder is\t";
b.preorder(visit); cout<<endl;
cout<<"Binary_tree B Recursive InOrder is\t";
b.inorder(visit); cout<<endl;
bool stop;
do
{ char choice; stop=false;
cout<<"\n Presst char( q--exit, i--Insert, d--Remove ) ";
cin>>choice;
switch (choice)
{ case 'q': stop=true; break;
case 'i':
cout<<"\ninput Insert Node value "; cin>>x;
b.insert(x);
break;
case 'd':
cout<<"\ninput Remove Node value "; cin>>x;
b.remove(x);
}
}while(!stop);
cout<<"\n Inorder After Remove node "<<x<<" of A is\t";
b.inorder(visit); cout<<endl;
cout<<"\nPreorder After Remove node "<<x<<" of A is\t";
b.preorder(visit); cout<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -