Muestra cuantas veces se repite un numero dado
pascal:
{-Victor De la Rocha}
{-Algoritmia@groups.msn.com}
{-www.myalgorithm.com}
uses
crt;
type
vector=array [1..100] of integer;
var
arreglo:vector;
cantidad,cont1,cont2,temp1,temp2,numero,veces:integer;
begin
ClrScr;
Write('Cantidad de valores: ');Readln(cantidad);
writeln;
for cont1:=1 to cantidad do
begin
Write('Valor ',cont1,': ');Readln(arreglo[cont1]);
end;
writeln;
for cont1:=cantidad downto 1 do
begin
for cont2:=1 to cont1 do
begin
if arreglo[cont1]1 then
begin
write('-Se repite ',veces,' veces el ''',numero,'''.');
end;
ReadKey;
end.
{-Algoritmia@groups.msn.com}
{-www.myalgorithm.com}
uses
crt;
type
vector=array [1..100] of integer;
var
arreglo:vector;
cantidad,cont1,cont2,temp1,temp2,numero,veces:integer;
begin
ClrScr;
Write('Cantidad de valores: ');Readln(cantidad);
writeln;
for cont1:=1 to cantidad do
begin
Write('Valor ',cont1,': ');Readln(arreglo[cont1]);
end;
writeln;
for cont1:=cantidad downto 1 do
begin
for cont2:=1 to cont1 do
begin
if arreglo[cont1]1 then
begin
write('-Se repite ',veces,' veces el ''',numero,'''.');
end;
ReadKey;
end.
Cantidad: 39 Valor 1: 3 Valor 2: 2 Valor 3: 2 Valor 4: 0 Valor 5: 1 Valor 6: 4 Valor 7: 1 Valor 8: 4 Valor 9: 2 Valor 10: 2 Valor 11: 2 Valor 12: 2 Valor 13: 3 Valor 14: 1 Valor 15: 0 Valor 16: 2 Valor 17: 3 Valor 18: 3 Valor 19: 4 Valor 20: 1 Valor 21: 0 Valor 22: 4 Valor 23: 3 Valor 24: 2 Valor 25: 0 Valor 26: 4 Valor 27: 2 Valor 28: 0 Valor 29: 4 Valor 30: 0 Valor 31: 4 Valor 32: 1 Valor 33: 2 Valor 34: 4 Valor 35: 0 Valor 36: 0 Valor 37: 0 Valor 38: 0 Valor 39: 2 Valor a buscar: 0 Veces encontrado: 10