привести 10 примеров с подробным описанием значений из реального мира, которые можно записать с типов данных алгоритмов: к какому типу отнести, и каким записать
1) var a: array [1..40] of integer; i, s1, s2: integer; begin for i := 1 to 40 do begin a[i] := random(20); writeln('a[', i, '] => ', a[i]); if (a[i] mod 2 = 1) then begin s1 := s1 + a[i]; inc(s2); end; end; writeln(s1 / s2); end.
2) var a: array [1..40] of integer; i, q: integer; begin for i := 1 to 40 do begin a[i] := random(20); writeln('a[', i, '] => ', a[i]); if (a[i] <= 10) then q := q + a[i]; end; writeln(q); end.
3) var a: array [1..40] of integer; i, w: integer; begin for i := 1 to 40 do begin a[i] := random(20); writeln('a[', i, '] => ', a[i]); if (a[i] mod 3 = 0) then w := w + a[i]; end; writeln(w); end.
A) program a1; uses crt; var m:array[1..40]of integer; i:byte; a,ka:integer; begin clrscr; a:=0;ka:=0; for i:=1 to 40 do begin m[i]:=random(21); if m[i] mod 2<>0 then begin ka:=ka+1; a:=a+m[i]; end; end; for i:=1 to 40 do if i=1 then write('M[',m[i],',') else if i=40 then writeln(m[i],']') else write(m[i],','); writeln('Среднее арифметическое нечетных чисел=',a/ka); end. b) program b1; uses crt; var m:array[1..40]of integer; i:byte; b:integer; begin clrscr; for i:=1 to 40 do begin m[i]:=random(21); begin if m[i]<=10 then b:=b+m[i]; end; end; for i:=1 to 40 do if i=1 then write('M[',m[i],',') else if i=40 then writeln(m[i],']') else write(m[i],','); writeln('Сумма чисел не превышающих 10=',b); end. в) program v1; uses crt; var m:array[1..40]of integer; i:byte; c:integer; begin clrscr; for i:=1 to 40 do begin m[i]:=random(21); begin if m[i] mod 3=0 then c:=c+m[i]; end; end; for i:=1 to 40 do if i=1 then write('M[',m[i],',') else if i=40 then writeln(m[i],']') else write(m[i],','); writeln('Сумма чисел кратных 3 = ',c); end.
var a: array [1..40] of integer;
i, s1, s2: integer;
begin
for i := 1 to 40 do
begin
a[i] := random(20);
writeln('a[', i, '] => ', a[i]);
if (a[i] mod 2 = 1) then
begin
s1 := s1 + a[i];
inc(s2);
end;
end;
writeln(s1 / s2);
end.
2)
var a: array [1..40] of integer;
i, q: integer;
begin
for i := 1 to 40 do
begin
a[i] := random(20);
writeln('a[', i, '] => ', a[i]);
if (a[i] <= 10) then q := q + a[i];
end;
writeln(q);
end.
3)
var a: array [1..40] of integer;
i, w: integer;
begin
for i := 1 to 40 do
begin
a[i] := random(20);
writeln('a[', i, '] => ', a[i]);
if (a[i] mod 3 = 0) then w := w + a[i];
end;
writeln(w);
end.
program a1;
uses crt;
var m:array[1..40]of integer;
i:byte;
a,ka:integer;
begin
clrscr;
a:=0;ka:=0;
for i:=1 to 40 do
begin
m[i]:=random(21);
if m[i] mod 2<>0 then
begin
ka:=ka+1;
a:=a+m[i];
end;
end;
for i:=1 to 40 do if i=1 then write('M[',m[i],',') else if i=40 then writeln(m[i],']') else write(m[i],',');
writeln('Среднее арифметическое нечетных чисел=',a/ka);
end.
b)
program b1;
uses crt;
var m:array[1..40]of integer;
i:byte;
b:integer;
begin
clrscr;
for i:=1 to 40 do
begin
m[i]:=random(21);
begin
if m[i]<=10 then b:=b+m[i];
end;
end;
for i:=1 to 40 do if i=1 then write('M[',m[i],',') else if i=40 then writeln(m[i],']') else write(m[i],',');
writeln('Сумма чисел не превышающих 10=',b);
end.
в)
program v1;
uses crt;
var m:array[1..40]of integer;
i:byte;
c:integer;
begin
clrscr;
for i:=1 to 40 do
begin
m[i]:=random(21);
begin
if m[i] mod 3=0 then c:=c+m[i];
end;
end;
for i:=1 to 40 do
if i=1 then write('M[',m[i],',')
else
if i=40 then writeln(m[i],']')
else
write(m[i],',');
writeln('Сумма чисел кратных 3 = ',c);
end.