-->

Seguidores

Tecnologia do Blogger.
Cursos Online na Área de Informática
Siga-nos
Twitter Facebook RSS
quarta-feira, 21 de setembro de 2011
program exe2;
// Autor: Cícero Amauri
const max = 5;
type
   pilha = record
              obj: array [1..max] of string;
              i: integer;
            end;
procedure criar (x: pilha);
  begin
    x.i := 0;
  end;
  procedure push(var x:pilha; y: string);
    begin
      x.i:= x.i +1;
      x.obj[x.i] := y;
    end;
    procedure pop (var x:pilha; y: string);
    var
      e, a: integer;
      ver: string;
    begin
       a := 0;
       repeat
          ver:= x.obj[x.i];
          x.i := x.i - 1;
          if (x.i = max) then
          e := 0;
             if (ver = y) then
             begin
                e:= e + 1;
                a:= 1
             end;
        if (x.i = 0 ) then
         begin
            writeln ('o elemento ',y,' repete ',e,' vezes na pilha');
         end;
         if (x.i = 0) and (a <> 1 ) then
 writeln ('o elemento não está na pilha');
 until (x.i = 0);      
end;
var
  p: pilha;
  elemento,busca: string;
  a : integer;
begin
  criar(p);
  for a := 1 to max do
  begin
    readln(elemento);
    push (p, elemento);
  end;
 writeln ('digite o elemento que deseja procurar ');
 readln (busca);
   pop(p, busca);
end.
Gostou? Compartilhe!

0 comentários:

Seu Sistema Operacional é...

TEMAS

Visualizações