基于链表法解决冲突问题的散列表
/*链接法解决哈希散列碰撞问题*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define N 20 //数组数量
#define Nhash 7 //哈希槽的数量
#define N_R 200
//每个数据结点
typedef struct node{
int key;
int num;
struct node * next;
struct node * pre;
}Node, *Pnode;
//哈希链表
typedef struct Hash{
Pnode link[N]; //每个链表的表头指针
int num; //哈希表中现存数据
int len; //哈希数组长度
}hash,*Phash;
Pnode IniPnode(int key){
Pnode p=(Pnode)malloc(sizeof(Node));
p->key=key;
p->num=1;
p->next=NULL;
p->pre=NULL;
}
//散列位置计算,当前使用取余数法
int HashPos(int key)<