writeln; writeln('Отсортированный массив'); for j := 1 to M do begin for i := 1 to N do write(arr[j, i] : 2, ' '); writeln; end; end.
matveevaev81
02.02.2021
{ Free Pascal }
procedure Println(a:array of integer); var i:integer; begin for i:=0 to Length(a)-1 do Write(a[i],' '); Writeln end;
procedure Ex1(var a:array of integer; var nn,np:integer); var i:integer; begin nn:=0; np:=0; for i:=0 to Length(a)-1 do if a[i]<0 then begin a[i]:=0; Inc(nn) end else if a[i]>0 then begin a[i]:=1; Inc(np) end end;
var a:array of integer; i,n,kp,kn:integer; begin Randomize; Write('Количество элементов: '); Read(n); SetLength(a,n); for i:=0 to n-1 do a[i]:=Random(41)-20; Println(a); Ex1(a,kn,kp); Writeln('Отрицательных ',kn,', положительных ',kp); Println(a) end.
M = 10; // Количество строк
N = 10; // Количество столбцов
var
arr: array [1..M, 1..N] of integer;
i,j,z,min,temp : integer;
begin
for j := 1 to M do
for i := 1 to N do
arr[j, i] := random(99);
writeln('Исходный массив:');
for j := 1 to M do
begin
for i := 1 to N do
write(arr[j, i] : 2, ' ');
writeln;
end;
for j := 1 to M do
begin
for i := 1 to N - 1 do
begin
min := i;
for z := i + 1 to N do
if arr[j, z] < arr[j, min] then
min := z;
temp := arr[j, min];
arr[j, min] := arr[j, i];
arr[j, i] := temp;
end;
end;
writeln;
writeln('Отсортированный массив');
for j := 1 to M do
begin
for i := 1 to N do
write(arr[j, i] : 2, ' ');
writeln;
end;
end.