标签:blog io ar os sp for div log bs
//哈希表---线性探测再散列 #include <iostream> #include <string> #include <stdio.h> #include <string.h> #define m 10000 #define NULLkey -1 using namespace std; int HashTable[m]; int Hash_search( int k) { int p0, pi; p0=hash(k); //函数运算值 if(HashTable[p0]== NULLkey ) { return -1; } else if(HashTable[p0]==k ) { return p0; } else //用线性探测再散列 解决冲突 { for(i=0; i<=m-1; i++) { pi=(p0+i)%m; if(HashTable[pi]==NULLkey ) { return -1; } else if(HashTable[pi]==k ) { return pi; } } return -1; } }
标签:blog io ar os sp for div log bs
原文地址:http://www.cnblogs.com/yspworld/p/4143913.html