-
大小: 11KB文件類型: .cpp金幣: 1下載: 0 次發(fā)布日期: 2021-01-06
- 語(yǔ)言: C/C++
- 標(biāo)簽:
資源簡(jiǎn)介
(1)每個(gè)人的信息至少包括姓名,電話,地址。至少包括對(duì)通訊錄的創(chuàng)建,添加和按姓名查找等功能。
(2)假設(shè)人名為漢語(yǔ)拼音全拼形式,待插入哈希表的長(zhǎng)度為你所在班級(jí)的人數(shù)。哈希函數(shù)用除留余數(shù)法構(gòu)造,采用鏈地址法或二次探測(cè)再散列法解決沖突。
(3)完成菜單設(shè)計(jì)。操作有必要的提示。
代碼片段和文件信息
#include?
#include?“math.h“
#include?“string.h“?
#include?“fstream“?
unsigned?int?Key1;?
unsigned?int?Key2;//Key1和Key2分別用電話號(hào)碼和姓名的關(guān)鍵字
using?namespace?std;//用來(lái)輸入/輸出流
#define?NULL?0
int?*p;?
struct?node?//建節(jié)點(diǎn)?
{?
????char?name[16]; //名字?
????char?address[20]; //地址?
????char?num[11];? //電話?
????node?*?next;? //結(jié)點(diǎn)指針?
};?
typedef?node*?pnode;?
typedef?node*?mingzi;?
node?**phone;? //指向結(jié)點(diǎn)指針phone的的指針?
node?**nam;? //指向結(jié)點(diǎn)指針nam的指針?
node?*a;?????
void?hash(char?num[11])?????//號(hào)哈希函數(shù)碼?
{??
????int?i?=?3;?????????????
????Key1=(int)num[2];???????
????while(num[i]!=NULL)?
{?
????????Key1+=(int)num[i];?
????????i++;?
}?
????Key1=Key1%20;? ?????//使用除留余數(shù)法?
}?
void?hash2(char?name[16])?//姓名哈希函數(shù)?
{?
????int?i?=?1;?
????Key2=(int)name[0];
????while(name[i]!
評(píng)論
共有 條評(píng)論