Const n=10; var ar:array[1..n] of integer; a,k,i:integer; begin Randomize; for i:=1 to n do begin ar[i]:=random(20)+1; write(ar[i]:3); end; writeln; write('a = '); readln(a); k:=0; for i:=1 to n do if ar[i] mod a = 0 then k:=k+1; writeln('k = ',k); end.
var ar:array[1..n] of integer;
a,k,i:integer;
begin
Randomize;
for i:=1 to n do
begin
ar[i]:=random(20)+1;
write(ar[i]:3);
end;
writeln;
write('a = ');
readln(a);
k:=0;
for i:=1 to n do
if ar[i] mod a = 0 then k:=k+1;
writeln('k = ',k);
end.
Пример:
15 2 20 13 12 2 7 14 2 4
a = 3
k = 2