-
Lenguaje
Pascal
-
Descripción
Pide al usuario 10 números, los guarda en un arreglo, ordena el arreglo de menor a mayor con el método de la burbuja y muestra el arreglo ordenado.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
program burbuja;
uses crt;
var aux : real;
var numeros : array[0..9] of real;
var i, j, n : integer;
var tecla : char;
begin
n := sizeof (numeros) div sizeof (real) - 1;
for i := 0 to n do
begin
write ('Ingrese el valor del elemento ', i, ': ');
readln (numeros[i]);
end;
for i:=1 to n do
for j := 0 to n - i do
if (numeros[j] > numeros[j + 1]) then
begin
aux := numeros[j];
numeros[j] := numeros[j + 1];
numeros[j + 1] := aux;
end;
writeln (#10#13'N'#163'meros ordenados:'#10#13);
for i:=0 to n do
writeln ('[', i , ']: ', numeros[i]:0:6);
write (#10#13'Presione una tecla para terminar . . . ');
tecla := readkey;
end.
uses crt;
var aux : real;
var numeros : array[0..9] of real;
var i, j, n : integer;
var tecla : char;
begin
n := sizeof (numeros) div sizeof (real) - 1;
for i := 0 to n do
begin
write ('Ingrese el valor del elemento ', i, ': ');
readln (numeros[i]);
end;
for i:=1 to n do
for j := 0 to n - i do
if (numeros[j] > numeros[j + 1]) then
begin
aux := numeros[j];
numeros[j] := numeros[j + 1];
numeros[j + 1] := aux;
end;
writeln (#10#13'N'#163'meros ordenados:'#10#13);
for i:=0 to n do
writeln ('[', i , ']: ', numeros[i]:0:6);
write (#10#13'Presione una tecla para terminar . . . ');
tecla := readkey;
end.