Const m = 3; n = 4; var a: array[1..m, 1..n] of integer; i, j, k, t: integer;
begin Randomize; Writeln('Исходный массив'); for i := 1 to m do begin for j := 1 to n do begin a[i, j] := Random(101) - 50; Write(a[i, j]:4) end; Writeln end; { Пузырьковая сортировка по возрастанию в столбцах } for j:=1 to n do for k := 1 to m-1 do for i := 1 to m-1 do if a[i,j] > a[i+1,j] then begin t := a[i,j]; a[i,j] := a[i+1,j]; a[i+1,j] := t end; Writeln('Сортировка по столбцам'); for i := 1 to m do begin for j := 1 to n do Write(a[i, j]:4); Writeln end end.
m = 3;
n = 4;
var
a: array[1..m, 1..n] of integer;
i, j, k, t: integer;
begin
Randomize;
Writeln('Исходный массив');
for i := 1 to m do
begin
for j := 1 to n do
begin
a[i, j] := Random(101) - 50;
Write(a[i, j]:4)
end;
Writeln
end;
{ Пузырьковая сортировка по возрастанию в столбцах }
for j:=1 to n do
for k := 1 to m-1 do
for i := 1 to m-1 do
if a[i,j] > a[i+1,j] then
begin t := a[i,j]; a[i,j] := a[i+1,j]; a[i+1,j] := t end;
Writeln('Сортировка по столбцам');
for i := 1 to m do
begin
for j := 1 to n do Write(a[i, j]:4);
Writeln
end
end.
Тестовое решение:
Исходный массив
49 -10 27 -22
46 42 -17 -12
34 -50 7 24
Сортировка по столбцам
34 -50 -17 -22
46 -10 7 -12
49 42 27 24