Professional Documents
Culture Documents
h> #define MAX 7 struct hashentry { int key; char name[10]; //int del; }table[MAX]; typedef struct hashentry entry; int func( int key) { int value= key%MAX; return value; } void insert(int k, const char* a) { int i; int h2=0; int h1=func(k); if(table[h1].key==-1) { table[h1].key=k; strcpy(table[h1].name,a); } else { i=1; while(table[h2].key!=-1) { h2=(h1+i)%MAX; i++; if(i>=MAX) { printf("\n out of space!"); exit(1); } } table[h2].key=k; strcpy(table[h2].name,a); } }// end func void display() { int i; for(i=0;i<MAX;i++) { printf("\n%d %s",table[i].key,table[i].name); } } int main() {