Две задачи по порядку)
1)
program example1;
var a,b,c,d,i:integer;
begin
for i:=1000 to 9999 do
begin
d:= i mod 10; //4
c:= i div 10 mod 10; //3
b:= i div 100 mod 10; //2
a:= i div 1000; //1
if ((a=d) and (b=c)) then write (i:5);
end;
end.
2)
program example2;
var a,b,c,d,i:integer;
h,j,k,l:boolean;
begin
write ('Введите четырехзначное число '); readln(i);
d:= i mod 10; //4
c:= i div 10 mod 10; //3
b:= i div 100 mod 10; //2
a:= i div 1000; //1
if (a<>0) and (a<>5) then write(a) else write('');
if (b<>0) and (b<>5) then write(b) else write('');
if (c<>0) and (c<>5) then write(c) else write('');
if (d<>0) and (d<>5) then write(d) else write('');
end.