Объяснение:
const
max_elements = 1000;
a = 1;
b = 15;
first_file_name = '1.txt';
second_file_name = '2.txt';
var
i, j, n, r:integer;
p:real;
ar:array[1..max_elements] of integer;
f1, f2:text;
begin
randomize;
writeln('Input n = ');
readln(n);
for i:=1 to n do begin
ar[i]:=random(b-a+1)+a;
end;
assign(f1, first_file_name);
rewrite(f1);
writeln(f1, ar[i]);
close(f1);
assign(f2, second_file_name);
rewrite(f2);
p:=1;
for j:=1 to i do
p:=p*ar[j];
writeln(f2, p:0:0);
close(f2);
readln;
end.
1.
a:array[1..1000] of integer;
i, n:integer;
count:integer;
writeln('Input a[', i, '] = ');
readln(a[i]);
count:=0;
i:=1;
while (i<=n) do begin
if (((a[i] mod 3) = 0) and ((a[i] - (a[i] div 10)*10) = 2)) then count:=count + 1;
i:=i+1;
writeln(count);
2.
repeat
until (i > n);
Объяснение:
const
max_elements = 1000;
a = 1;
b = 15;
first_file_name = '1.txt';
second_file_name = '2.txt';
var
i, j, n, r:integer;
p:real;
ar:array[1..max_elements] of integer;
f1, f2:text;
begin
randomize;
writeln('Input n = ');
readln(n);
for i:=1 to n do begin
ar[i]:=random(b-a+1)+a;
end;
assign(f1, first_file_name);
rewrite(f1);
for i:=1 to n do begin
writeln(f1, ar[i]);
end;
close(f1);
assign(f2, second_file_name);
rewrite(f2);
for i:=1 to n do begin
p:=1;
for j:=1 to i do
p:=p*ar[j];
writeln(f2, p:0:0);
end;
close(f2);
readln;
end.
Объяснение:
1.
var
a:array[1..1000] of integer;
i, n:integer;
count:integer;
begin
writeln('Input n = ');
readln(n);
for i:=1 to n do begin
writeln('Input a[', i, '] = ');
readln(a[i]);
end;
count:=0;
i:=1;
while (i<=n) do begin
if (((a[i] mod 3) = 0) and ((a[i] - (a[i] div 10)*10) = 2)) then count:=count + 1;
i:=i+1;
end;
writeln(count);
readln;
end.
2.
var
a:array[1..1000] of integer;
i, n:integer;
count:integer;
begin
writeln('Input n = ');
readln(n);
for i:=1 to n do begin
writeln('Input a[', i, '] = ');
readln(a[i]);
end;
count:=0;
i:=1;
repeat
if (((a[i] mod 3) = 0) and ((a[i] - (a[i] div 10)*10) = 2)) then count:=count + 1;
i:=i+1;
until (i > n);
writeln(count);
readln;
end.