//Pascal
//1)
var
A: array [1..20] of integer;
i, j, k: integer;
begin
randomize;
writeln('***Сгенерированный массив***');
for i := 1 to 20 do
begin
A[i] := random(200)+100;
write(A[i]:4);
end;
for i := 1 to 20-1 do
for j := 1 to 20-i do
if A[j] > A[j+1] then
begin
k := A[j];
A[j] := A[j+1];
A[j+1] := k;
end;
writeln;
writeln('***Массив после сортировки***');
for i := 1 to 20 do
write(A[i]:4);
readln;
end.
//2)
var
A: array [1..10, 1..10] of integer;
i, j, k, N, M, buf: integer;
begin
randomize;
writeln(' ***Сгенерированный массив***');
for i := 1 to 10 do
begin
for j := 1 to 10 do
begin
A[i, j] := random(51);
write(A[i, j]:4);
end;
writeln;
end;
write('Введите номер столбца для сортировки: ');
readln(M);
for j:=m to m do
begin
for k:=1 to 10 do
for i := 10 downto k+1 do
if A[i-1,j]>A[i,j] then
begin
buf:=A[i,j];
A[i,j]:=A[i-1,j];
A[i-1,j]:=buf;
end;
end;
writeln;
writeln(' ***Массив после сортировки***');
for i := 1 to 10 do
begin
for j := 1 to 10 do
write(A[i, j]:4);
writeln;
end;
write('Введите номер строки для сортировки: ');
readln(N);
for i:=n to n do
for j:=1 to 10-1 do
for k:=j+1 to 10 do
if A[i,j]>A[i,k] then
begin
buf:=a[i,j];
A[i,j]:=A[i,k];
A[i,k]:=buf;
end;
writeln;
writeln(' ***Массив после сортировки***');
for i := 1 to 10 do
begin
for j := 1 to 10 do
write(A[i, j]:4);
writeln;
end;
readln;
end.