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;
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.
"1 * 4 + 1 + 1 + 1 + 1 * 4 = 32"
"1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 * 4 = 32"
"1 * 4 + 1 + 1 + 1 * 4 + 1 + 1 + 1 + 1 = 32"
"1 + 1 + 1 + 1 + 1 + 1 + 1 * 4 + 1 + 1 + 1 + 1 = 32"
"1 * 4 + 1 + 1 * 4 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 32"
"1 + 1 + 1 + 1 + 1 + 1 * 4 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 32"
"1 * 4 + 1 * 4 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 32"
"1 + 1 + 1 + 1 + 1 * 4 + 1 + 1 + 1 + 1 + 1 + 1 + 1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