Simula una pila y una cola con valores aleatoreos
pascal:
{-Victor De la Rocha}
{-Algoritmia@groups.msn.com}
{-www.myalgorithm.com}
{-Sin Fecha}
{-Sin nombre}
{-Sin Explicacion}
uses
crt;
const
CANTIDAD=10;
var
arreglo:array [1..CANTIDAD] of integer;
c1,c2,c3,c4:integer;
begin
ClrScr;
randomize;
writeln('entrada de valores');
for c1:=1 to CANTIDAD do
begin
arreglo[c1]:=random(100);
write(arreglo[c1],', ');
end;
writeln;
{simulacion de la cola}
writeln;
writeln('Cola');
for c1:=1 to CANTIDAD do
begin
write(arreglo[c1],', ');
end;
{fin de la simulacion de cola}
writeln;
writeln;
writeln('Pila');
for c1:=CANTIDAD downto 1 do
begin
write(arreglo[c1],', ');
end;
ReadKey;
end.
{-Algoritmia@groups.msn.com}
{-www.myalgorithm.com}
{-Sin Fecha}
{-Sin nombre}
{-Sin Explicacion}
uses
crt;
const
CANTIDAD=10;
var
arreglo:array [1..CANTIDAD] of integer;
c1,c2,c3,c4:integer;
begin
ClrScr;
randomize;
writeln('entrada de valores');
for c1:=1 to CANTIDAD do
begin
arreglo[c1]:=random(100);
write(arreglo[c1],', ');
end;
writeln;
{simulacion de la cola}
writeln;
writeln('Cola');
for c1:=1 to CANTIDAD do
begin
write(arreglo[c1],', ');
end;
{fin de la simulacion de cola}
writeln;
writeln;
writeln('Pila');
for c1:=CANTIDAD downto 1 do
begin
write(arreglo[c1],', ');
end;
ReadKey;
end.
Entrada de valores: 62, 25, 38, 60, 3, 87, 51, 82, Simulacion de COLA: FIFO: First In, First Out 62, 25, 38, 60, 3, 87, 51, 82, Simulacion de PILA: FILO: First In, Last Out 82, 51, 87, 3, 60, 38, 25, 62,