#include<iostream>
#include<string>
#include <conio.h>
#include<windows.h>
#include <stdlib.h>
#include "HashTableTel.h"
#include "HashTableUser.h"
using namespace std;
/** 限制存储最大的记录条数 */
#define MAXSIZE 200
//存储输入记录的结构定义
typedef struct {
string userName;
string telephone;
string address;
}Note;
//以电话号码为关键字建立散列表的类
HashTableTel hashTel;
//以用户名为关键字建立散列表的类
HashTableUser hashUser;
// 初始化的最大记录数
Note note[MAXSIZE];
//一条记录,电话号码,用户名,地址
string telephone,user,address;
//存储实际的记录条数
int count = 0;
/*
* 序号 1 添加所有用户信息
*/
void add() {
cout<<"请输入用户记录条数:";
cin>>count;
if(count == 0) {
cout<<"添加了0条记录"<<endl;
cout<<"按任意键返回主菜单!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
return;
}
for(int i = 0; i < count; i++) {
cout<<endl<<"请输入第"<<(i+1)<<"条记录:"<<endl;
cout<<"用户名:";
cin>>user;
cout<<"电话号码:";
cin>>telephone;
cout<<"地址:";
cin>>address;
note[i].userName = user;
note[i].telephone = telephone;
note[i].address = address;
}
cout<<endl<<"记录输入完毕,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 2 显示所有用户信息
*/
void putall() {
for(int i = 0; i < count; i++)
cout<<"用户名: "<<note[i].userName<<" 电话号码: "<<note[i].telephone<<" 地址: "<<note[i].address<<endl;
cout<<endl<<"记录输出完毕,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 3 以用户名建立哈希表
*/
void createUser() {
for(int i = 0; i < count; i++)
hashUser.put(note[i].userName,note[i].telephone,note[i].address);
cout<<endl<<"创建完成,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 4 以电话号码建立哈希表
*/
void createTel() {
for(int i = 0; i < count; i++)
hashTel.put(note[i].telephone,note[i].userName,note[i].address);
cout<<endl<<"创建完成,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 5 查找给定用户名的记录
*/
void searchUser() {
string userName;
cout<<"输入要查询的用户名:";
cin>>userName;
hashUser.get(userName);
cout<<endl<<"信息输出完毕,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 6 查找给定电话号码的记录
*/
void searchTel() {
string telephone;
cout<<"输入要查询的电话号码:";
cin>>telephone;
hashTel.get(telephone);
cout<<endl<<"信息输出完毕,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 7 添加单条记录到以用户名建立的哈希表中
*/
void AddsingleUser() {
cout<<"用户名:";
cin>>user;
cout<<"电话号码:";
cin>>telephone;
cout<<"地址:";
cin>>address;
hashUser.put(user,telephone,address);
cout<<endl<<"记录输入完毕,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 序号 8 添加单条记录到以电话号码建立的哈希表中
*/
void AddsingleTel() {
cout<<"电话号码:";
cin>>telephone;
cout<<"用户名:";
cin>>user;
cout<<"地址:";
cin>>address;
hashTel.put(telephone,user,address);
cout<<endl<<"记录输入完毕,按任意键返回主菜单!!!!!!!"<<endl;
}
/*
* 密码检查
*/
void access() {
string pwd;
while (1){
printf("\n ┏〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓┓");
printf("\n ┃ ┃");
printf("\n ┃ ※※※※※※※※※※※※※※※※※※ ┃");
printf("\n ┃ ※※★欢迎使用电话号码查找系统★※※ ┃");
printf("\n ┃ ※※※※※※※※※※※※※※※※※※ ┃");
printf("\n ┃ ┃");
printf("\n ┗〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓┛");
printf("\n");
cout<<endl<<" password:";
cin>>pwd;
if(pwd == "baiyan") {
cout<<endl<<"password is right!!!"<<endl<<"press any key access to system!!!";
getch();
return;}
if(pwd !="baiyan") {
cout<<endl<<"password is wrong! you have only two chance!"<<endl<<endl;
cout<<"password:";
cin>>pwd;
}
if(pwd == "baiyan") {
cout<<endl<<"password is right!!!"<<endl<<"press any key access to system!!!";
getch();
return;}
if(pwd !="baiyan") {
cout<<endl<<"password is wrong! you have only one chance!"<<endl<<endl;
cout<<"password:";
cin>>pwd;
}
if(pwd == "baiyan") {
cout<<endl<<"password is right!!!"<<endl<<"press any key access to system!!!";
getch();
return;}
if(pwd !="baiyan") {
cout<<endl<<"password is wrong! you have no chance!"<<endl<<endl;
cout<<"system is exiting……"<<endl;
exit(0);
}
}
}
int main() {
//序号
int number;
access();
while (1){
printf("\n ※※※※※※※※※※※※※※ ");
printf("\n ※※★电话号码查找系统★※※ ");
printf("\n ※※※※※※※※※※※※※※ ");
printf("\n ┏〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓┓");
printf("\n ┃ ┃");
printf("\n ┃★ ☆ ★ ☆ ★ ☆ ★散列表的设计与实现★ ☆ ★ ☆ ★ ☆ ★┃");
printf("\n ┃ ┃");
printf("\n ┃【1】.一次性添加所有用户信息 ┃");
printf("\n ┃【2】.显示一次性添加的所有用户信息 ┃");
printf("\n ┃【3】.以用户名建立哈希表(链地址解决冲突) ┃");
printf("\n ┃【4】.以电话号码建立哈希表(链地址解决冲突) ┃");
printf("\n ┃【5】.查找并显示给定用户名的记录 ┃");
printf("\n ┃【6】.查找并显示给定电话号码的记录 ┃");
printf("\n ┃【7】.添加单条记录到以用户名建立的哈希表中 ┃");
printf("\n ┃【8】.添加单条记录到以电话号码建立的哈希表中 ┃");
printf("\n ┃【9】.退出程序 ┃");
printf("\n ┃ ┃");
printf("\n ┃ 温馨提示: ┃");
printf("\n ┃ Ⅰ.进行5操作前 请先操作3 ┃");
printf("\n ┃ Ⅱ.进行6操作前 请先操作4 ┃");
printf("\n ┃ ┃");
printf("\n ┗〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓┛");
printf("\n");
cout<<endl<<endl<<"请输入序号:";
//输入序号
cin>>number;
switch(number) {
case 1:
add(); //添加所有用户信息
getch();
break;
case 2:
putall(); //显示所有用户信息
getch();
break;
case 3:
createUser();//以用户名建立哈希表
getch();
break;
case 4:
createTel();//以电话号码建立哈希表
getch();
break;
case 5:
searchUser();//查找并显示给定用户名的记录
getch();
break;
case 6:
searchTel();//查找并显示给定电话号码的记录
getch();
break;
case 7:
AddsingleUser();//添加单条记录到以用户名建立的哈希表中
getch();
break;
case 8:
AddsingleTel();//添加单条记录到以电话号码建立的哈希表中
getch();
break;
case 9:
exit(0);//正常结束
break;
default:
cout<<endl<<"序号错误!!!";
cout<<endl<<"按任意键返回主菜单,重新输入!!!!!!!"<<endl;
getch();
}
}
return 0;
}
//结束
没有合适的资源?快使用搜索试试~ 我知道了~
课程设计散列表的设计与实现
共26个文件
cpp:5个
obj:5个
h:4个
4星 · 超过85%的资源 需积分: 50 25 下载量 149 浏览量
2010-10-07
17:55:20
上传
评论 4
收藏 2.25MB RAR 举报
温馨提示
散列表的设计与实现,课程设计. 设计散列表实现电话号码查找系统。 【基本要求】 1) 设每个记录有下列数据项:电话号码、用户名、地址; 2) 从键盘输入各记录,分别以电话号码和用户名为关键字建立散列表; 3) 采用一定的方法解决冲突; 4) 查找并显示给定电话号码的记录; 5) 查找并显示给定用户名的记录。 【进一步完成内容】 1) 系统功能的完善; 2) 设计不同的散列函数,比较冲突率; 3) 在散列函数确定的前提下,尝试各种不同类型处理冲突的方法,考察平均查找长度的变化。
资源推荐
资源详情
资源评论
收起资源包目录
优秀散列表的设计与实现.rar (26个子文件)
2008180530白艳
2008湖南师范大学工学院电子与信息工程系课程设计报告书.doc 531KB
源代码
main.cpp 8KB
HashTableUser.cpp 2KB
HashTableTel.cpp 2KB
Cbaiyan.dsp 5KB
Cbaiyan.dsw 522B
note.cpp 371B
FunctionCode.h 689B
Cbaiyan.opt 55KB
Debug
HashTableTel.obj 78KB
HashTableUser.obj 78KB
vc60.pdb 140KB
vc60.idb 345KB
note.obj 14KB
Cbaiyan.exe 576KB
Cbaiyan.ilk 833KB
main.obj 298KB
Cbaiyan.pch 5.14MB
FunctionCode.obj 21KB
Cbaiyan.pdb 1.39MB
Cbaiyan.plg 1KB
FunctionCode.cpp 1KB
note.h 664B
Cbaiyan.ncb 105KB
HashTableUser.h 908B
HashTableTel.h 919B
共 26 条
- 1
资源评论
- qinzebin1232012-07-08控制台界面做得很棒,代码结构清晰,组织严密。有设计文档和完整工程,对于做这个题目参考下很有用的。
- gao5118353922013-06-17设计的不错,很有用
- fengzhongyuqi2014-06-25看得出作者用心了,但是为什么编译能通过,但是连接有问题??更别说运行了?
bynlzq
- 粉丝: 74
- 资源: 59
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功