BSTreeTest.cpp
上传用户:fafc_zi
上传日期:2022-07-28
资源大小:3k
文件大小:1k
- #include"BSTree.h"
- #include<cstdlib>
- using namespace std;
- int main(){
- BinaryTree<int> btree[9];
- char ch;
- int i,j,n[9]={100,200,300,500,1000,2000,3000,5000,10000},k[7];
- for(j=0;j<9;j++){
- for(i=0;i<n[j];i++) btree[j].Creat(rand());
- cout<<endl<<"中序:"<<endl;
- btree[j].InOrder(); //中序遍历输出升序
- cout<<endl;
- cout<<endl<<"树元素数为:"<<n[j]<<'t'<<"树深度为:"<<endl;
- k[j]=btree[j].Countdepth();
- cout<<k[j]<<endl;
- cout<<"继续运行吗?"<<endl;
- cin>>ch;
- if(ch!='y'&&ch!='Y') break;
- }
- return 0;
- }