// (Hash)
#include
#include
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define SUCCESS 1
#define UNSUCCESS 0
#define HASHSIZE 7
#define NULLKEY -32768
typedef int Status;
typedef struct
{
int *elem; //
int count; //
}HashTable;
int m=0; //
/* */
Status Init(HashTable *hashTable)
{
int i;
m=HASHSIZE;
hashTable->elem = (int *)malloc(m * sizeof(int)); //
hashTable->count=m;
for (i=0;ielem[i]=NULLKEY;
}
return OK;
}
/* ( )*/
int Hash(int data)
{
return data % m;
}
/* */
void Insert(HashTable *hashTable,int data)
{
int hashAddress=Hash(data); //
//
while(hashTable->elem[hashAddress]!=NULLKEY)
{
//
hashAddress=(++hashAddress)%m;
}
//
hashTable->elem[hashAddress]=data;
}
/* */