Var n, k, i, imax, j: integer; a: array[1..100]of integer;
begin randomize; n := random(30) + 10; for i := 1 to n do begin a[i] := Random(30); write(a[i], ' '); end; writeln();
{сортировочка} for i := 1 to n - 1 do begin imax := i; for j := i + 1 to n do if a[j] > a[imax] then imax := j; k := a[i]; a[i] := a[imax]; a[imax] := k; end;
for i := 1 to n do write(a[i], ' ');
k := 0; for i := 2 to n - 1 do if (a[i] <> a[i - 1]) and (a[i] <> a[i + 1]) then k := k + 1;
if a[1] <> a[2] then k := k + 1; if a[n] <> a[n - 1] then k := k + 1;
Var i,j,k:longint; begin for i:=1 to 1000 do for j:=1 to 1000 do for k:=1 to 10000 do if sqr(i)+sqr(j)=sqr(K)then begin writeln(i,' ',j,' ',k); {вывожу все тройки, можно убрать} if i+j+k=1000 then begin writeln('! ',i,' ',j,' ',k); {нужная тройка} exit; {прерывание программы} end; end; end.
n, k, i, imax, j: integer;
a: array[1..100]of integer;
begin
randomize;
n := random(30) + 10;
for i := 1 to n do
begin
a[i] := Random(30);
write(a[i], ' ');
end;
writeln();
{сортировочка}
for i := 1 to n - 1 do
begin
imax := i;
for j := i + 1 to n do
if a[j] > a[imax] then
imax := j;
k := a[i];
a[i] := a[imax];
a[imax] := k;
end;
for i := 1 to n do
write(a[i], ' ');
k := 0;
for i := 2 to n - 1 do
if (a[i] <> a[i - 1]) and (a[i] <> a[i + 1]) then
k := k + 1;
if a[1] <> a[2] then k := k + 1;
if a[n] <> a[n - 1] then k := k + 1;
writeln();
writeln('No doubles - ', k);
end.
i,j,k:longint;
begin
for i:=1 to 1000 do
for j:=1 to 1000 do
for k:=1 to 10000 do
if sqr(i)+sqr(j)=sqr(K)then
begin
writeln(i,' ',j,' ',k); {вывожу все тройки, можно убрать}
if i+j+k=1000 then
begin
writeln('! ',i,' ',j,' ',k); {нужная тройка}
exit; {прерывание программы}
end;
end;
end.