Контрольная работа: Программирование решения задач
const
n = 20;
var
arr : array [1..n] of byte;
tmp, i, j, k : byte;
begin
randomize;
for i := 1 to n do arr[i] := random(3);
for i := 1 to n do
for j := i to n do
if arr[i] < arr[j] then
begin
tmp := arr[i];
arr[i] := arr[j];
arr[j] := tmp;
end;
for i := 1 to n do if arr[i] = 1 then
begin
k :=i;
break;
end;
for i := k to n do
for j := i to n do
if arr[i] > arr[j] then
begin
tmp := arr[i];
arr[i] := arr[j];
arr[j] := tmp;
end;