Var max1,max2,min1,min2,i:integer; ar:array[1..n] of integer; begin max1:=integer.MinValue; max2:=integer.MinValue; min1:=integer.MaxValue; min2:=integer.MaxValue; for i:=1 to n do begin readln(ar[i]); if (ar[i]<max1) and (ar[i]>max2) then max2:=ar[i] else if ar[i]>max1 then begin max2:=max1; max1:=ar[i]; end; if (ar[i]>min1) and (ar[i]<min2) then min2:=ar[i] else if ar[i]<min1 then begin max2:=max1; min1:=ar[i]; end; end; writeln('Сумма максимумов:',max1+max2); writeln('Cумма минимумов:',min1+min2); end.
Пример ввода: 1 2 3 4 5 Пример вывода: Сумма максимумов:9 Cумма минимумов:3
Var
N,A:integer;
Begin
Write('N = ');Read(N);
A:=0;
While N>0 do
Begin
if (N mod 10) > A then A:= N mod 10;
N:=N div 10;
End;
Write(A)
End.
Var
N,A,B:integer;
C:boolean;
Begin
Write('N = ');Read(N);
A:=-1;
B:=-2;
C:=false;
While N>0 do
Begin
if A=B then C:=true;
if N>0 then
Begin
A:=N mod 10;
N:=N div 10;
End;
if A=B then C:=true;
if N>0 then
Begin
B:=N mod 10;
N:=N div 10;
End;
End;
if A=B then C:=true;
if C then Write('Есть')
else Write('Нет')
End.
Подробнее - на -