Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM tp10ej2;
- uses T_caja;
- type
- lista= ^nodo;
- nodo = record
- datos: caja;
- sig: lista;
- end;
- lista1 = ^nodo1;
- nodo1 = record
- datoC: caja;
- sig: lista;
- end;
- Arbol = ^nodo2;
- nodo2 = record
- datos: lista1;
- izq: arbol;
- der: arbol;
- end;
- var
- l:lista {cajas desordenadas}
- a: Arbol;
- procedure AgregarLista_Arbol (var l:lista1; x: caja);
- var nue: lista1;
- begin
- new(nue);
- nue^.datos:= x;
- nue^.sig:= l;
- l:= nue;
- end;
- procedure crearNodo_Arbol (var A: arbol; x:caja);
- begin
- if (A = nil) then begin
- New (A);
- a^.cant:= 0;
- AgregarLista_Arbol (A^.datos,x);
- A^.izq:= nil;
- A^.der:= nil;
- end
- else
- if (verPeso(x) < verPeso(A^.datos^.datoC)) then crearNodo_Arbol (A^.izq, x);
- else
- if (verPeso(x) > verPeso(A^.datos^.datoC)) then crearNodo_Arbol (A^.der, x);
- else
- AgregarLista_Arbol (A^.datos, x);
- end;
- BEGIN
- act:= l;
- while (act <> nil ) do begin {recorre lista de cajas}
- crearNodo_Arbol (A, act^.datos^.datoC);
- act:= act^.sig;
- end;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement