program SumSeq;
{$APPTYPE CONSOLE}
uses
SysUtils;
//const m:Integer ;
var
i, j, m, s:Integer;
n: array of Integer;
begin
s:=0;
Writeln(m);
Writeln('vvedite m');
Readln(m);
SetLength(n,m);
for i:=0 to m do
begin
j:=Random(10);
if j<5
then n[i]:=-1*j
else n[i]:=j;
write(n[i], ' ')
end;
Writeln;
Writeln('To continue push >>ENTER');
Readln;
for i:=0 to m do
begin
if n[i]<0
then s:=s+sqr(n[i])
end;
writeln('s=',s);
readln
{ TODO -oUser -cConsole Main : Insert code here }
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.