Помогите решить задачку:
ЛОБ+ТРИ=САМ, где каждой букве соответствует цифра, найти все возможные решения.-> т.е. число1+число2=числу3 .
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
l,o,b,t,r,i,c,a,m : 0..9;
dig : set of 0..9;
cam: longint;
sum : longint;
begin
for l:=0 to 9 do begin
include(dig,l);
for o:=0 to 9 do
if not (o in dig) then begin
include(dig,o);
for b:=0 to 9 do
if not (b in dig) then begin
include(dig,b);
for t:=0 to 9 do
if not (t in dig) then begin
include(dig,t);
for r:=0 to 9 do
if not (r in dig) then begin
include(dig,r);
for i:=0 to 9 do
if not (i in dig) then begin
include(dig,i);
for c:=0 to 9 do
if not (c in dig) then begin
include(dig,c);
for a:=0 to 9 do
if not (a in dig) then begin
include(dig,a);
for m:=0 to 9 do
if not (m in dig) then begin
include(dig,m);
sum:=(l+t)*100+(o+r)*10+b+i;
cam:=c*100+a*10+m;
if (sum=cam) then writeln('',l,o,b,'+',t,r,i,'=',c,a,m);
exclude(dig,m);
end;
exclude(dig,a);
end;
exclude(dig,c);
end;
exclude(dig,i);
end;
exclude(dig,r);
end;
exclude(dig,t);
end;
exclude(dig,b);
end;
exclude(dig,o);
end;
exclude(dig,l);
end;
readln;
end.