proginternet.com

Programacion Internet

  • Unidad Pila Implementacion del TADA para PASCAL
    Codigo:
    unit upila ;

    INTERFACE
    CONST MAX_PILA = 10;
    type
    tpila = Record
    Cima : Integer;
    Elementos : Array[1..MAX_PILA] of Integer;
    End;

    IMPLEMENTATION

    Procedure crear(Var pila : tpila);
    begin
    pila.cima := 0
    end;

    Function vacia(Var pila : tpila) : Boolean;
    begin
    vacia := pila.cima = 0
    end;

    Function llena(Var pila : tpila) : Boolean;
    begin
    llena := pila.cima = MAX_PILA
    end;

    Procedure apilar(Var pila : tpila; elem : integer);
    begin
    Inc(pila.cima);
    pila.elementos[pila.cima] := elem
    end;

    Procedure desapilar(Var pila : tpila; Var elem : integer);
    begin
    elem := pila.elementos[pila.cima];
    dec(pila.cima)
    end;
    end.

    Original post by admin and software by Elliott Back

    No Comments