Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. int main(int argc, char *argv[]) {
  2. TipoArvore a = NULL;
  3. TipoChave c,b,vetor[95],m;
  4. b = 'f';
  5. int i = 0, j, k, n;
  6. int min = 32, max = 126;
  7. while(b != '9') {
  8. scanf("%c", &b);
  9. vetor[i] = b;
  10. i++; // o contador esta sendo acrescido 2 vezes antes de dar scanf denovo... DISNEY
  11. printf("\n%d", i);
  12. }
  13. scanf("%c", &m); // Ta pulando esse scanf aqui.
  14.  
  15. for(j = 0; j < i; j = j+2) {
  16. c = vetor[j];
  17. printf("Inserindo chave: %c\n", c); //esta printando esse printf duas vezes
  18. a = Insere(c, &a);
  19. Pesquisa(c,a);
  20. }
  21. Pesquisa(m,a);
  22. }
  23. ==========================================================================================
  24. Inserção na Patricia
  25. ==========================================================================================
  26.  
  27. TipoArvore Insere(TipoChave k, TipoArvore *t)
  28. { TipoArvore p;
  29. int i;
  30. if (*t == NULL)
  31. return (CriaNoExt(k));
  32. else
  33. { p = *t;
  34. while (!EExterno(p))
  35. { if (Bit(p->NO.NInterno.Index, k) == 1)
  36. p = p->NO.NInterno.Dir;
  37. else p = p->NO.NInterno.Esq;
  38. }
  39. /* acha o primeiro bit diferente */
  40. i = 1;
  41. while ((i <= D) & (Bit((int)i, k) == Bit((int)i, p->NO.Chave)))
  42. i++;
  43. if (i > D)
  44. { printf("Erro: chave ja esta na arvore\n"); return (*t); }
  45. else return (InsereEntre(k, t, i));
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement