type massiv = array [2..21] of integer; var mass : massiv; i, summa : integer;
begin summa := 0; for i:=2 to 21 do begin mass[i]:=i; if (mass[i] mod 2 = 0) then summa := summa + mass[i] end; writeln('Сумма четных эл-тов равна : ', summa); readln; end.
program z; var a : array[2..21] of integer; i,summ : integer; b : array[2..21] of integer;
begin for i:= 2 to 21 do begin a[i]:=i; end;
for i:=2 to 21 do begin if a[i] mod 2 = 0 then begin b[i]:=a[i]; end;
end;
summ:=0; for i:=2 to 21 do begin summ:=summ+b[i]; end; Writeln(summ); readln;
Var a:array[1..5] of integer; i,Max,c,n,f:integer; procedure ho; begin if a[i]>Max then begin Max:=a[i]; c:=i; end; end;
begin for i:=1 to 5 do begin a[i]:= random(15)+2; write(a[i],' '); end; Max:=a[1]; c:=1; for i:=1 to 5 do ho; writeln; writeln('Максимум: ',max); f:=c; if f=1 then begin max:=a[2]; for i:=2 to 5 do ho; writeln('Вторичный максимум: ',max); exit; end; if f<5 then begin Max:=a[f+1]; for i:=f+1 to 5 do ho; n:=max; end; if f>1 then begin Max:=a[1]; c:=f; for i:=1 to c-1 do ho; if max>n then writeln('Вторичный максимумì: ',max); if max<n then writeln('Вторичный максимум: ',n); end; end.
massiv = array [2..21] of integer;
var
mass : massiv;
i, summa : integer;
begin
summa := 0;
for i:=2 to 21 do
begin
mass[i]:=i;
if (mass[i] mod 2 = 0) then
summa := summa + mass[i]
end;
writeln('Сумма четных эл-тов равна : ', summa);
readln;
end.
program z;
var
a : array[2..21] of integer;
i,summ : integer;
b : array[2..21] of integer;
begin
for i:= 2 to 21 do
begin
a[i]:=i;
end;
for i:=2 to 21 do
begin
if a[i] mod 2 = 0 then
begin
b[i]:=a[i];
end;
end;
summ:=0;
for i:=2 to 21 do
begin
summ:=summ+b[i];
end;
Writeln(summ);
readln;
end.
a:array[1..5] of integer;
i,Max,c,n,f:integer;
procedure ho;
begin
if a[i]>Max then
begin
Max:=a[i];
c:=i;
end;
end;
begin
for i:=1 to 5 do
begin
a[i]:= random(15)+2;
write(a[i],' ');
end;
Max:=a[1];
c:=1;
for i:=1 to 5 do
ho;
writeln;
writeln('Максимум: ',max);
f:=c;
if f=1 then
begin
max:=a[2];
for i:=2 to 5 do
ho;
writeln('Вторичный максимум: ',max); exit;
end;
if f<5 then
begin
Max:=a[f+1];
for i:=f+1 to 5 do
ho;
n:=max;
end;
if f>1 then
begin
Max:=a[1];
c:=f;
for i:=1 to c-1 do
ho;
if max>n then
writeln('Вторичный максимумì: ',max);
if max<n then
writeln('Вторичный максимум: ',n);
end;
end.