Первое
var
a:array[1..100] of integer;
i,j:integer;
procedure swap(var x,y: integer);
var t: integer;
begin
t := x;
x := y;
y := t
end;
begin
for i:=1 to 100 do a[i]:=random(100);
for j:=1 to 99 do
for i:=1 to 100-j do if a[i] > a[i+1] then swap(a[i],a[i+1]);
for i:=2 to 99 do if (a[i]=a[i+1]) or (a[i]=a[i-1]) then writeln('a[',i,']=',a[i]);
end.
Второе
var
a:array[1..100] of integer;
i,j:integer;
procedure swap(var x,y: integer);
var t: integer;
begin
t := x;
x := y;
y := t
end;
begin
for i:=1 to 100 do a[i]:=random(100);
for j:=1 to 99 do
for i:=1 to 100-j do if a[i] > a[i+1] then swap(a[i],a[i+1]);
if a[1]<>a[2] then writeln('a[1]=',a[1]);
for i:=2 to 99 do if (a[i]<>a[i+1]) and (a[i]<>a[i-1]) then writeln('a[',i,']=',a[i]);
if a[100]<>a[99] then writeln('a[100]=',a[100]);
end.