Está en la página 1de 3

(* UNIVERSIDAD NACIONAL ABIERTA

ÁREA DE INGENIERÍA
CARRERA INGENIERÍA INDUSTRIAL

El presente programa tiene como objetivo obtener los 3 valores mas altos
sin importar el orden y excluyendo repeticiones entre los valores,
estos seran obtenidos mediante el ingreso manual por parte del usuario.
Ejemplo, si un ususraio ingresa 5, 7, 8, 8, 70, 70
la salida sera: 7,8,70

Elaborado por:
Dora Contrera

*)

program project1;
var
i, n, input: integer;
principal: array[1..15] of integer;
auxiliar: array[1..15] of integer;

function cabecera_programa():integer;
begin
writeln(' UNIVERSIDAD NACIONAL ABIERTA');
writeln('TRABAJO PRACTICO DE LA ASIGNATURA COMPUTACION I (COD. 323) 2023-1');
writeln('');
writeln('Dora Contrera');
writeln('');
writeln('Determinar los 3 valores maximo');
end;

function mostrar_valor_maximo():integer;
var
i,j,valor,index: integer;
begin
writeln('Los 3 valores maximos');
for i := 0 to 2 do
begin
valor := 0;
for j := 0 to n-1 do
if(auxiliar[j] > valor) then
begin
valor := auxiliar[j];
index := j;
end;
auxiliar[index] := 0;
writeln(valor);
end;
end;

function pocos_valores():integer;
var
i: integer;
begin
writeln('Los 3 valores maximos');
for i := 0 to n-1 do
begin
writeln(principal[i]);
end;
end;

function purgar_array():integer;
var
i,j: integer;
begin
for i := 0 to n-1 do
begin
writeln('#');
for j := 0 to n-1 do
begin
if principal[i] = auxiliar[j] then
begin
writeln(principal[j], ' : ',auxiliar[i]);
Break;
end
else
begin
auxiliar[i] := principal[i];
Break;
end;

end;
end;
end;

begin

cabecera_programa();
writeln('Cuantos valores desea ingresar: (maximo 15)');
read(n);
i:=0;
writeln('Ingresando ', n, ' valores');

if(n >= 16) then


begin
writeln('Valores exedidos!');
readln();
exit;
end;

repeat
read(principal[i]);
i:=i+1;
until (i >= n) or (n >= 16);

if n <= 3 then
begin
pocos_valores();
end
else
begin
purgar_array();
mostrar_valor_maximo();
end;
write('Presione enter para salir...');
readln();
readln();
end.

También podría gustarte