mam takyto problem : na ulohu sme dostali vyriesit kryptogram
DONALD + GERALD = ROBERT a mal vyjst iba jeden vysledok podla nasho profesora a to je 526485 + 197485 = 723970 a mne s tochto programu vyslo ze ich tam je asi 11 program je takyto :
Kód: Vybrať všetko
program donald;
uses crt;
var q1,q2,q3,d,o,n,a,l,g,e,r,b,t,p:integer; {donald,gerald,robert}
begin
clrscr;
writeln('DONALD+ GERALD = ROBERT');
p:=1;
for d:=1 to 5 do
for o:=0 to 9 do
if o<>d then
for n:=0 to 9 do
if (n<>d) and (n<>o) then
for a:=0 to 9 do
if (a<>d) and (a<>o) and (a<>n) then
for l:=0 to 9 do
if (l<>d) and (l<>o) and (l<>n) and (l<>a) then
for g:=1 to 5 do
if (g<>d) and (g<>o) and (g<>n) and (g<>a) and (g<>l) then
for e:=0 to 9 do
if (e<>d) and (e<>o) and (e<>n) and (e<>a) and (e<>l) and (e<>g) then
for r:=1 to 9 do
if (r<>d) and (r<>o) and (r<>n) and (r<>a) and (r<>l) and (r<>g) and (r<>e) then
for b:=0 to 9 do
if (b<>d) and (b<>o) and (b<>n) and (b<>a) and (b<>l) and (b<>g) and (b<>e) and (b<>r) then
for t:=0 to 9 do
if (t<>d) and (t<>o) and (t<>n) and (t<>a) and (t<>l) and (t<>g) and (t<>e) and (t<>r) and (t<>b) then
begin
q1:=d+10*l+100*a+1000*n+10000*o+100000*d;
q2:=d+10*l+100*a+1000*r+10000*e+100000*g;
q3:=t+10*r+100*e+1000*b+10000*o+100000*r;
if q1+q2=q3 then begin
writeln('Riesenie cislo ',p);
writeln;
writeln('Vysledok je ');
writeln(' D=',d,' O=',o,' N=',n,' A=',a,' L=',l,' G=',g,' E=',e,' R=',r,' B=',b,' T=',t);
writeln(d,o,n,a,l,d,' + ',g,e,r,a,l,d,' = ',r,o,b,e,r,t);
p:=p+1;
readln;
writeln;
end;
end;
readln;
end.