#include #define TAMHASH 113 struct registro{ int prio; char nome[30]; struct registro *prox; }; struct registro *tabela[TAMHASH]; int hash( char *n) { int i, h; for( i=0, h=1; n[i]!='\0'; ++i) { h = (h * n[i]) % TAMHASH; } printf("Funcao hash de <%s> deu <%d>\n", n, h); return h; } void insere( int p, char *n) { struct registro *novo; int h; if( (novo = (struct registro *) malloc( sizeof(struct registro))) == NULL ) { printf("Erro na alocacao\n"); exit(1); } novo->prio = p; strcpy( novo->nome, n); h = hash(n); novo->prox = tabela[h]; tabela[h] = novo; } struct registro * consulta( char *n) { int h; struct registro *x; h = hash(n); x = tabela[h]; while( x != NULL && strcmp( n, x->nome) != 0 ) x = x->prox; return x; } int main( int argc, char *argv[]) { int i; struct registro *p; for(i=0; iprio); }