-
Lenguaje
PSeInt (Pseudocódigo)
-
Descripción
Obtener el número más cercano a 1000 en una cantidad de datos.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Proceso NumeroMasCercanoA1000
mas_cercano <- 0;
residuo_mas_cercano <- 0;
Escribir Sin Saltar "Ingresa el valor de n:";
Leer n;
Para i<-1 Hasta n Con Paso 1 Hacer
Escribir "PROCESO ", i;
Escribir Sin Saltar "Ingresa el valor de un numero:";
Leer un_numero;
Si un_numero<1000 Entonces
residuo <- 1000-un_numero;
SiNo
residuo <- un_numero-1000;
FinSi
Si i=1 O residuo<residuo_mas_cercano Entonces
mas_cercano <- un_numero;
residuo_mas_cercano <- residuo;
FinSi
Escribir "Valor de residuo: ", residuo;
Escribir "";
FinPara
Escribir "Valor de mas cercano: ", mas_cercano;
Escribir "Valor de residuo mas cercano: ", residuo_mas_cercano;
FinProceso
mas_cercano <- 0;
residuo_mas_cercano <- 0;
Escribir Sin Saltar "Ingresa el valor de n:";
Leer n;
Para i<-1 Hasta n Con Paso 1 Hacer
Escribir "PROCESO ", i;
Escribir Sin Saltar "Ingresa el valor de un numero:";
Leer un_numero;
Si un_numero<1000 Entonces
residuo <- 1000-un_numero;
SiNo
residuo <- un_numero-1000;
FinSi
Si i=1 O residuo<residuo_mas_cercano Entonces
mas_cercano <- un_numero;
residuo_mas_cercano <- residuo;
FinSi
Escribir "Valor de residuo: ", residuo;
Escribir "";
FinPara
Escribir "Valor de mas cercano: ", mas_cercano;
Escribir "Valor de residuo mas cercano: ", residuo_mas_cercano;
FinProceso