begin var a: array[1..N] of real; var i: integer; var growing: boolean;
for i := 1 to N do begin readln(a[i]); end;
growing := true;
for i := 2 to N do begin if a[i] <= a[i - 1] then begin growing := false; break; end; end;
writeln(growing); end.
const m = 5; const n = 4; const limit = 100;
begin var matrix: array[1..m] of array[1..n] of real; var matrixb: array[1..m - 1] of array[1..n - 1] of real; var row, col, rb, cb, lowest_row, lowest_col: integer; var lowest: real; var p: boolean;
lowest := limit;
for row := 1 to m do begin for col := 1 to n do begin matrix[row][col] := random(limit - 1); if matrix[row][col] < lowest then begin lowest := matrix[row][col]; lowest_col := col; lowest_row := row; end; write(matrix[row][col], ' '); end; writeln(''); end;
writeln(''); writeln(lowest); writeln('');
rb := 1;
for row := 1 to m do begin p := false; cb := 1; for col := 1 to n do begin if (not (col = lowest_col)) and (not (row = lowest_row)) then begin p := true; matrixb[rb][cb] := matrix[row][col]; cb := cb + 1; end; end; if p then begin rb := rb + 1; end; end;
for rb := 1 to m - 1 do begin for cb := 1 to n - 1 do begin write(matrixb[rb][cb], ' '); end; writeln(''); end;
PascalABC.NET 3.3.5, сборка 1662 от 29.04.2018 Внимание! Если программа не работает, обновите версию!
begin var n:=ReadInteger('Количество строк/столбцов в матрице:'); Writeln('*** Исходная матрица ***'); var a:=MatrRandom(n,n,-99,99); a.Println(4); Writeln(n*4*'-'); var b:=a.Rows.Select(row->row.Where(t->t.IsOdd).DefaultIfEmpty.Average) .ToArray; b.Println; end.
begin
var a: array[1..N] of real;
var i: integer;
var growing: boolean;
for i := 1 to N do begin
readln(a[i]);
end;
growing := true;
for i := 2 to N do begin
if a[i] <= a[i - 1] then begin
growing := false;
break;
end;
end;
writeln(growing);
end.
const m = 5;
const n = 4;
const limit = 100;
begin
var matrix: array[1..m] of array[1..n] of real;
var matrixb: array[1..m - 1] of array[1..n - 1] of real;
var row, col, rb, cb, lowest_row, lowest_col: integer;
var lowest: real;
var p: boolean;
lowest := limit;
for row := 1 to m do begin
for col := 1 to n do begin
matrix[row][col] := random(limit - 1);
if matrix[row][col] < lowest then begin
lowest := matrix[row][col];
lowest_col := col;
lowest_row := row;
end;
write(matrix[row][col], ' ');
end;
writeln('');
end;
writeln('');
writeln(lowest);
writeln('');
rb := 1;
for row := 1 to m do begin
p := false;
cb := 1;
for col := 1 to n do begin
if (not (col = lowest_col)) and (not (row = lowest_row)) then begin
p := true;
matrixb[rb][cb] := matrix[row][col];
cb := cb + 1;
end;
end;
if p then begin
rb := rb + 1;
end;
end;
for rb := 1 to m - 1 do begin
for cb := 1 to n - 1 do begin
write(matrixb[rb][cb], ' ');
end;
writeln('');
end;
end.
Внимание! Если программа не работает, обновите версию!
begin
var n:=ReadInteger('Количество строк/столбцов в матрице:');
Writeln('*** Исходная матрица ***');
var a:=MatrRandom(n,n,-99,99);
a.Println(4); Writeln(n*4*'-');
var b:=a.Rows.Select(row->row.Where(t->t.IsOdd).DefaultIfEmpty.Average)
.ToArray;
b.Println;
end.
Пример
Количество строк/столбцов в матрице: 5
*** Исходная матрица ***
40 -38 16 -70 26
87 7 -31 99 34
-34 -47 -33 32 56
66 71 41 7 80
55 42 -22 7 86
0 40.5 -40 39.6666666666667 31