Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. PROGRAM tp10ej2;
  2.  
  3. uses T_caja;
  4.  
  5. type
  6.  
  7. lista= ^nodo;
  8.  
  9. nodo = record
  10. datos: caja;
  11. sig: lista;
  12. end;
  13.  
  14. lista1 = ^nodo1;
  15.  
  16. nodo1 = record
  17. datoC: caja;
  18. sig: lista;
  19. end;
  20.  
  21.  
  22. Arbol = ^nodo2;
  23.  
  24. nodo2 = record
  25. datos: lista1;
  26. izq: arbol;
  27. der: arbol;
  28. end;
  29.  
  30.  
  31. var
  32.  
  33. l:lista {cajas desordenadas}
  34.  
  35. a: Arbol;
  36.  
  37. procedure AgregarLista_Arbol (var l:lista1; x: caja);
  38. var nue: lista1;
  39. begin
  40. new(nue);
  41. nue^.datos:= x;
  42. nue^.sig:= l;
  43. l:= nue;
  44. end;
  45.  
  46.  
  47. procedure crearNodo_Arbol (var A: arbol; x:caja);
  48. begin
  49. if (A = nil) then begin
  50. New (A);
  51. a^.cant:= 0;
  52. AgregarLista_Arbol (A^.datos,x);
  53. A^.izq:= nil;
  54. A^.der:= nil;
  55. end
  56. else
  57. if (verPeso(x) < verPeso(A^.datos^.datoC)) then crearNodo_Arbol (A^.izq, x);
  58. else
  59. if (verPeso(x) > verPeso(A^.datos^.datoC)) then crearNodo_Arbol (A^.der, x);
  60. else
  61. AgregarLista_Arbol (A^.datos, x);
  62. end;
  63.  
  64.  
  65. BEGIN
  66. act:= l;
  67. while (act <> nil ) do begin {recorre lista de cajas}
  68. crearNodo_Arbol (A, act^.datos^.datoC);
  69. act:= act^.sig;
  70. end;
  71. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement