Advertisement
antogv98

Untitled

Mar 20th, 2020
1,880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.83 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.    primero, ultimo : enlace;
  10.    function vacia return boolean is
  11.    begin
  12.       return primero = null;
  13.    end vacia;
  14.    procedure poner (E: elemento) is
  15.       nuevo: enlace;
  16.    begin
  17.       nuevo:= new nodo;
  18.       Nuevo.contenido:=E;
  19.       Nuevo.siguiente:=null;
  20.       if vacia then
  21.          primero:=nuevo;
  22.       else
  23.          Ultimo.siguiente:= nuevo;
  24.       end if;
  25.       ultimo:=Nuevo;
  26.    end poner;
  27.    procedure quitar(E: out elemento) is
  28.       viejo: enlace;
  29.    begin
  30.       viejo:=Primero;
  31.       E:=viejo.contenido;
  32.       Primero:=viejo.siguiente;
  33.       if primero = null then
  34.          ultimo:= null;
  35.       end if;
  36.    end quitar;
  37. end cola;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement