--- на Python ---
from random import*
n = int(input('Введите размерность массива : '))
a=[0]*n
for i in range (0,n):
a[i] = randint(0,2)
print(a)
a = sorted(a)
--- на pascal подходит для Delphi и Lazarus ---
var
a : array of integer;
i, j, n : integer;
begin
randomize;
writeln('Input n');
readln(n);
SetLength(a,n);
for i := 0 to n - 1 do begin
a[i] := random(3);
write(a[i]);
end;
i:=0;
while i < n-1 do
if a[i]>a[i+1] then begin
j := a[i];
a[i] := a[i+1];
a[i+1] := j;
end
else
inc(i);
writeln('');
for i := 0 to n - 1 do
end.
--- на Python ---
from random import*
n = int(input('Введите размерность массива : '))
a=[0]*n
for i in range (0,n):
a[i] = randint(0,2)
print(a)
a = sorted(a)
print(a)
--- на pascal подходит для Delphi и Lazarus ---
var
a : array of integer;
i, j, n : integer;
begin
randomize;
writeln('Input n');
readln(n);
SetLength(a,n);
for i := 0 to n - 1 do begin
a[i] := random(3);
write(a[i]);
end;
i:=0;
while i < n-1 do
if a[i]>a[i+1] then begin
j := a[i];
a[i] := a[i+1];
a[i+1] := j;
i:=0;
end
else
inc(i);
writeln('');
for i := 0 to n - 1 do
write(a[i]);
end.