Can't read (SU) AH ~ ~
#include <cstdio> #include <cstring> #include <cstdlib> #define Hashsize 12#define Nullkey- 32768typedef struct {int *elem;int count;} Hashtable;int m=0;int inithashtable (HashTable *h) {int i;m = hashsize; H->count = m; H->elem = (int *) malloc (sizeof (int) *m); for (i=0;i<m;i++) h->elem[i] = Nullkey;return 1;} int Hash (int key) {return key%m;//remainder method}void inserthash (HashTable *h,int key) {int addr = Hash (key); while (h->elem[addr ] = Nullkey) {addr = (addr+1)% m;} H->ELEM[ADDR] = key;} int Searchhash (HashTable h,int key,int *addr) {*addr = Hash (key); while (h.elem[*addr]! = key) {//no *addr = (*addr+1)% m;//toward Next look if (h.elem[*addr] = = Nullkey | | *addr = = Hash (key)) {//not | | Back to beginning return 0;}} return 1;} int main () {int a[] = {12,67,56,16,25,37,22,29,15,47,48,34};int i;int key;int addr; HashTable h;inithashtable (&h); for (i=0;i<12;i++) {Inserthash (&h,a[i]);} while (~SCANF ("%d", &key)) {if (Searchhash (H,KEY,&ADDR)) printf ("%d\n", addr), Else printf ("Can ' t Find it!\n");} return 0;}
Find-Hash list