#include<iostream.h>
#include"hashList1.h"
#include "LinkHashList1.h"
void UseArrayHashList();
void UseLinkHashList();
void main()
{
UseArrayHashList();
cout<<endl;
UseLinkHashList();
cout<<endl;
}
void UseArrayHashList()
{
ArrayHashList ht;
int m;
InitHashList(ht,m);
ElemType x;
ElemType a[7]={45,28,34,50,66,73,82};
int i,j;
cout<<"向散列表插入了数组a[7]={45,28,34,50,66,73,82}中";
cout<<"的所有元素!"<<endl;
for(i=0;i<7;i++)Insert(ht,m,a[i]);
cout<<"从键盘上输入一批整数插入到散列表中,用-1作为结束!"<<endl;
do {
cin>>x;
if(x==-1)break;
Insert(ht,m,x);
} while(1);
PrintHashList(ht,m);
cout<<"从键盘上输入一批待从散列表中删除的整数,用-1作为结束!"<<endl;
do {
cin>>x;
if(x==-1)break;
Delete(ht,m,x);
} while(1);
PrintHashList(ht,m);
cout<<"从键盘上输入一批待从散列表中查找的整数,用-1作为结束!"<<endl;
do {
cin>>x;
if(x==-1)break;
if((j=Search(ht,m,x))!=-1)
cout<<"从散列表中查找"<<x<<"成功!返回下标值为"<<j<<endl;
else
cout<<"从散列表中查找"<<x<<"失败!"<<endl;
} while(1);
cout<<"从键盘上输入两个整数插入到散列表中!"<<endl;
for(i=0;i<2;i++){
cin>>x;
Insert(ht,m,x);
}
PrintHashList(ht,m);
DeleteHashList(ht);
}
void UseLinkHashList()
{
LinkHashList ht;
int m;
InitHashList(ht,m);
ElemType x;
ElemType a[7]={45,28,34,50,66,73,82};
int i;
cout<<"向散列表插入了数组a[7]={45,28,34,50,66,73,82}中";
cout<<"的所有元素!"<<endl;
for(i=0;i<7;i++)Insert(ht,m,a[i]);
cout<<"从键盘上输入一批整数插入到散列表中,用-1作为结束!"<<endl;
do {
cin>>x;
if(x==-1)break;
Insert(ht,m,x);
} while(1);
PrintHashList(ht,m);
cout<<"从键盘上输入一批待从散列表中删除的整数,用-1作为结束!"<<endl;
do {
cin>>x;
if(x==-1)break;
Delete(ht, m, x);
}while(1);
PrintHashList(ht, m);
cout<<"从键盘上输入一批待从散列表中查找的整数,用-1作为结束!"<<endl;
do {
cin>>x;
if(x==-1)break;
ElemType* y;
if((y=Search(ht,m,x))!=NULL)
cout<<"散列表中查找"<<x<<"成功!返回地址值为"<<y<<endl;
else
cout<<"从散列表中查找"<<x<<"失败!"<<endl;
} while(1);
cout<<"从键盘上输入两个整数插入到散列表中!"<<endl;
for(i=0;i<2;i++){
cin>>x;
Insert(ht,m,x);
}
PrintHashList(ht,m);
DeleteHashList(ht,m);
}
没有合适的资源?快使用搜索试试~ 我知道了~
基本散列表的线性探查法
共21个文件
cpp:3个
obj:3个
pdb:2个
需积分: 15 21 下载量 147 浏览量
2009-01-06
12:27:07
上传
评论 1
收藏 268KB RAR 举报
温馨提示
数据结构基本的操作,作用不大,但是思路清晰,值得一看!
资源详情
资源评论
资源推荐
收起资源包目录
.rar (21个子文件)
散列表操作
散列表操作.dsp 4KB
hashList1.h 391B
LinkHashList1.h 443B
hashListMain1.cpp 2KB
Debug
vc60.pdb 60KB
散列表操作.ilk 252KB
vc60.idb 65KB
hashListMain1.obj 12KB
散列表操作.pch 240KB
散列表操作.exe 212KB
LinkHashList1.obj 15KB
散列表操作.pdb 521KB
hashList1.obj 14KB
散列表操作.opt 49KB
散列表操作.plg 1KB
Visual Studio 2005
Backup Files
散列表操作
hashList1.cpp 2KB
散列表操作.sln 351B
散列表操作.ncb 41KB
LinkHashList1.cpp 2KB
散列表操作.dsw 545B
散列表操作.suo 7KB
共 21 条
- 1
gameboy2009
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0