// PascalABC.NET 3.1, сборка 1200 от 13.03.2016 begin var a:=MatrixRandom(7,7,0,9); var k:=0; for var i:=0 to 6 do begin for var j:=0 to 6 do begin Write(a[i,j]:3); if a[i,j] in [1..5] then Inc(k) end; Writeln end; Writeln('Кол-во элементов на [1,5]: ',k) end.
const n=7; var a:array[1..n,1..n] of integer; i,j,k:integer; begin Randomize; k:=0; for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=Random(10); Write(a[i,j]:3); if a[i,j] in [1..5] then Inc(k) end; Writeln end; Writeln('Кол-во элементов на [1,5]: ',k) end.
var mas1, mas2: array[0..9] of integer; t, k, i, j: integer; begin readln(t); readln(k); for j := 0 to 1 do begin if (j = 1) then writeln(); for i := 0 to 9 do begin if(j = 0) then begin mas1[i] := random(100); write(mas1[i], ' '); if mas1[i] > t Then mas1[i] := mas1[i] + 4; end else begin mas2[i] := random(100); write(mas2[i], ' '); if mas2[i] > 10 * K Then mas2[i] := mas2[i] + K; end; end; for i := 0 to 9 do if (j = 0) then write(mas1[i]) else write(mas2[i]); writeln(); end; readln(); end.
begin
var a:=MatrixRandom(7,7,0,9);
var k:=0;
for var i:=0 to 6 do begin
for var j:=0 to 6 do begin
Write(a[i,j]:3);
if a[i,j] in [1..5] then Inc(k)
end;
Writeln
end;
Writeln('Кол-во элементов на [1,5]: ',k)
end.
Тестовое решение:
2 1 7 3 3 2 7
9 2 9 2 0 5 5
4 2 6 9 4 6 0
1 0 3 5 4 5 9
6 3 6 0 2 0 8
0 8 4 3 2 1 8
6 0 4 4 5 4 0
Кол-во элементов на [1,5]: 27
Вариант "совсем для школы"
const
n=7;
var
a:array[1..n,1..n] of integer;
i,j,k:integer;
begin
Randomize;
k:=0;
for i:=1 to n do begin
for j:=1 to n do begin
a[i,j]:=Random(10);
Write(a[i,j]:3);
if a[i,j] in [1..5] then Inc(k)
end;
Writeln
end;
Writeln('Кол-во элементов на [1,5]: ',k)
end.
begin
readln(t);
readln(k);
for j := 0 to 1 do begin
if (j = 1) then writeln();
for i := 0 to 9 do begin
if(j = 0) then begin
mas1[i] := random(100);
write(mas1[i], ' ');
if mas1[i] > t Then mas1[i] := mas1[i] + 4;
end
else
begin
mas2[i] := random(100);
write(mas2[i], ' ');
if mas2[i] > 10 * K Then
mas2[i] := mas2[i] + K;
end;
end;
for i := 0 to 9 do
if (j = 0) then
write(mas1[i])
else
write(mas2[i]);
writeln();
end;
readln();
end.
))