const nx = 20; var x: array[1..nx, 1..nx] of integer;z:array[1..nx*2] of integer; i, j, k,n,r,t: integer; begin Writeln('Введите размер матрицы n');Read(n); for i := 1 to n do begin for j := 1 to n do begin Read(k);x[i, j] := k; end;end; Writeln('Исходный массив'); for i := 1 to n do begin for j := 1 to n do begin Write(x[i, j]:4); if x[i, j]>0 then begin t:=t+1; z[t]:=x[i, j];end; end; Writeln; end; Writeln;Writeln('Одномерный массив'); for j := 1 to t do Write(z[j]:4); end.
PascalABC.NET
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
Println('Результат:', (a.Max + a.Min) / 2)
end.
Turbo Pascal
program abcd;
uses Crt;
const
nn = 100;
var
i, n, max, min: integer;
a: array[1..nn] of integer;
begin
ClrScr;
Write('n = ');
Readln(n);
Randomize;
max := -32768;
min := 32767;
for i := 1 to n do
begin
a[i] := Random(199) - 99;
Write(a[i], ' ');
if a[i] > max then
max := a[i]
else if a[i] < min then
min := a[i]
end;
Writeln;
Writeln('Результат: ', (max + min) / 2);
ReadKey
end.
var x: array[1..nx, 1..nx] of integer;z:array[1..nx*2] of integer;
i, j, k,n,r,t: integer;
begin
Writeln('Введите размер матрицы n');Read(n);
for i := 1 to n do begin
for j := 1 to n do begin
Read(k);x[i, j] := k; end;end;
Writeln('Исходный массив');
for i := 1 to n do begin
for j := 1 to n do begin
Write(x[i, j]:4);
if x[i, j]>0 then begin t:=t+1; z[t]:=x[i, j];end;
end;
Writeln; end;
Writeln;Writeln('Одномерный массив');
for j := 1 to t do
Write(z[j]:4);
end.