#include "StaticSearch.h"
#include "DynamicSearch.h"
void main()
{
int i;
KeyType key;
SSTable table;
BSTree root=NULL;
inittable(table,10);
cout<<"新建查找表中的数据:\n";
outputtable(table);
cout<<"输入顺序查找的关键字:\n";
cin>>key;
cout<<"顺序查找的结果:"<<Search_Seq(table, key)<<"\n";
sorttable(table);
cout<<"排序后的查找表中的数据:\n";
outputtable(table);
cout<<"输入折半查找的关键字:\n";
cin>>key;
cout<<"折半查找的结果:"<<Search_Bin(table, key)<<"\n";
KeyType KeyArray[11]={15,6,18,3,7,17,20,2,4,13,9};
BSTree p=NULL;
ElemType e;
CreateBST(root,KeyArray,11);
cout<<"新建二叉排序树中的数据:\n";
InorderTraverse(root);
cout<<"\n输入待查找的数据:\n";
cin>>key;
cout<<"查找的结果:\n";
SearchBSTree(root,key,p,NULL);
if (p==NULL)
cout<<"查找失败!"<<"\n";
else
cout<<"查找成功:"<<p->data.key<<"\n";
cout<<"输入待插入的数据:\n";
cin>>e.key;
InsertBSTree(root,e,p);
cout<<"插入新数据之后的二叉排序树:\n";
InorderTraverse(root);
cout<<"\n输入待删除的数据:\n";
cin>>key;
DeleteBSTree(root,key);
cout<<"删除之后的二叉排序树:\n";
InorderTraverse(root);
}