type
massiv = array [1..10] of integer;
var
mass : massiv;
i , j , n , b: integer;
begin
randomize;
write('Введите длину массива : ');readln(n);
for i:=1 to n do
mass[i] := random(10);
write(mass[i], ' ');
end;
for i:=1 to n-1 do
for j:=1 to n-i do
if (mass[j] < mass[j+1]) then
b := mass[j];
mass[j] := mass[j+1];
mass[j+1] := b;
writeln;
readln;
end.
Объяснение:
type
massiv = array [1..10] of integer;
var
mass : massiv;
i , j , n , b: integer;
begin
randomize;
write('Введите длину массива : ');readln(n);
for i:=1 to n do
begin
mass[i] := random(10);
write(mass[i], ' ');
end;
for i:=1 to n-1 do
for j:=1 to n-i do
begin
if (mass[j] < mass[j+1]) then
begin
b := mass[j];
mass[j] := mass[j+1];
mass[j+1] := b;
end;
end;
writeln;
for i:=1 to n do
write(mass[i], ' ');
readln;
end.
Объяснение: