Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.88 KB | None | 0 0
  1. package body Cola is
  2.    type Nodo;
  3.    type Enlace is access Nodo;
  4.    type Nodo is
  5.       record
  6.          Contenido : Elemento;
  7.          Siguiente : Enlace;
  8.       end record;
  9.    
  10.    Primero, Ultimo : Enlace := null;
  11.    
  12.    function Vacia return Boolean is
  13.    begin
  14.       return Primero = null;
  15.    end Vacia;
  16.    
  17.    procedure Poner(E:Elemento) is
  18.       Nuevo : Enlace;
  19.    begin
  20.       Nuevo := new Nodo;
  21.       Nuevo.Contenido := E;
  22.       Nuevo.Siguiente := null;
  23.       if Vacia then
  24.          Primero := Nuevo;
  25.       else
  26.          Ultimo.Siguiente := Nuevo;
  27.       end if;
  28.       Ultimo:=Nuevo;
  29.    end Poner;
  30.    
  31.    procedure Quitar(E: out Elemento) is
  32.       Viejo: Enlace;
  33.    begin
  34.       Viejo:=Primero;
  35.       E:=Viejo.Contenido;
  36.       Primero:=Viejo.Siguiente;
  37.       if Primero = null then
  38.          Ultimo := null;
  39.       end if;
  40.    end Quitar;
  41.    
  42. end Cola;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement