Uses crt;
const n=12;
var m:array[1..n] of integer;
k,s,i:integer;
begin
randomize;
for i:=1 to n do
begin
m[i]:=random(9)+1;
writeln(m[i]);
if m[i] mod 2<>0 then begin inc(k); s:=s+m[i]; end;
end;
writeln;
writeln(k);
writeln(s);
end.
Const nmax = 5;
var a:array [1..nmax] of integer;
i,k:integer;
begin
k:=0;
randomize;
for i:=1 to nmax do
begin
a[i]:=random(11)+10;
write (a[i],' ');
if a[i] mod 5 = 0 then inc(k);
end;
writeln;
writeln ('Kol-vo: ',k);
end.
//Pascal
//1)
var
A: array[1..5, 1..8] of integer;
i, j: byte;
sumR, sumC: integer;
begin
randomize;
writeln('Исходный массив':28);
for i := 1 to 5 do
begin
for j := 1 to 8 do
begin
A[i, j] := random(61)-30;
write(A[i,j]:5);
if i = 3 then sumR := sumR + A[i, j];
if j = 5 then sumC := sumC + A[i, j];
end;
writeln;
end;
writeln('Сумма элементов 5 столбца = ', sumC);
writeln('Сумма элементов 3 строки = ', sumR);
end.
//2)
var
A: array[1..5, 1..8] of integer;
i, j: byte;
sumA, sumB, countV, countG: integer;
begin
randomize;
writeln('Исходный массив':28);
for i := 1 to 5 do
begin
for j := 1 to 8 do
begin
A[i, j] := random(300)-150;
write(A[i,j]:5);
if ((i = 5) and (A[i, j] < 0)) then sumA := sumA + A[i, j];
if ((j = 4) and (A[i, j] < 100)) then sumB := sumB + A[i, j];
if ((i = 4) and (A[i, j] < 5)) then countV := countV + 1;
if ((j = 2) and (A[i, j] > 15)) then countG := countG + 1;
end;
writeln;
end;
writeln('Сумма отрицательных 5 строки = ', sumA);
writeln('Сумма меньших 100 4-ого столбца = ', sumB);
writeln('Количество меньших 5 4-ой строки = ', countV);
writeln('Количество ненулевых, больших 15 2-ого столбца = ', countG);
end.
Clock.tt,blink.uta,blocker.htm,elpack.ty упр 122.123 =click.txt,lo3ck.sts,blink.uta
Const n=10;
var ar:array[1..n] of integer;
a,p,i:integer;
begin
write('a = ');
readln(a);
write('p = ');
readln(p);
ar[1]:=a;
for i:=2 to n do ar[i]:=ar[i-1]+p;
for i:=1 to n do write(ar[i],' ');
end.
Пример:
a = 2
p = 5
2 7 12 17 22 27 32 37 42 47