Три варианта решения:
1)
var
s: string;
i, min: integer;
begin
readln(s);
min := 10;
for i := 1 to length(s) do
if(strtoint(s[i]) < min) then min := strtoint(s[i]);
s := s + inttostr(min);
s := inttostr(min) + s;
writeln(s);
end.
2)
var
a, n, i, min, tmp, m: integer;
begin
m := 1;
read(a);
tmp := a;
n := 0;
min := 10;
while tmp > 0 do
begin
n := n + 1;
if(tmp mod 10 < min) then min := tmp mod 10;
tmp := tmp div 10;
end;
for i := 1 to n do
m := m * 10;
a := a + (min * m);
a := a * 10;
a := a + min;
if(min=0)then write(0,a)
else write(a)
end.
3)
var
a, i, min, tmp: integer;
begin
read(a);
tmp := a;
min := 10;
while tmp > 0 do
begin
if(tmp mod 10 < min) then min := tmp mod 10;
tmp := tmp div 10;
end;
write(min, a, min);
end.