#include <iostream.h>
typedef int KeyType;
#include "DataType.h"
#include "HashTable.h"
#include "stdlib.h"
void main(void)
{
int i, j,n=10;
cout<<"请输入哈希表长度(11或者13)"<<endl;
int x;cin>>x;
HashTable myHashTable(x);
DataType a[]={100,150,200,250,300,350,400,450,500,550};
DataType item;
for(i = 0; i < n; i++)
myHashTable.Insert(a[i]);
for(i = 0; i < n; i++)
{
j = myHashTable.Find(a[i]);
if(j > 0)
{
item = myHashTable.GetValue(j);
cout << "j = " << j << " ht[] = " << item.key << endl;
}
}
char m='y';
for(;m!='n' && m!='N';)
{
cout<<"请输入要查找的数"<<endl;
int y;cin>>y;
int k = myHashTable.IsIn(y);
if(k == 1) cout << "数据元素"<<y<<"在哈希表中"<<endl;
else cout << "数据元素"<<y<<"不在哈希表中"<<endl;
cout<<"是否继续查找,输入Y或者N"<<endl;
cin>>m;
}
system("pause");
}