Составить алгоритм решения ребуса МУХА + МУХА + МУХА = СЛОН (различные буквы обозначают различные цифры, старшая — не 0).

Может кто объяснить решение
var m,u,h,a,s,l,o,n: integer;
begin
for m:=1 to 9 do
for s:=1 to 9 do
for u:=0 to 9 do
for h:=0 to 9 do
for a:=0 to 9 do
for l:=0 to 9 do
for o:=0 to 9 do
for n:=0 to 9 do
if (((m*1000)+(u*100)+(h*10)+a)*3=(s*1000)+(l*100)+(o*10)+n)
and ((m<>u) and (m<>h) and (m<>a) and (m<>s) and (m<>l) and (m<>o) and (m<>n)
and (u<>h) and (u<>a) and (u<>s) and (u<>l) and (u<>o) and (u<>n)
and (h<>a) and (h<>s) and (h<>l) and (h<>o) and (h<>n)
and (a<>s) and (a<>l) and (a<>o) and (a<>n)
and (s<>l) and (s<>o) and (s<>n)
and (l<>o) and (l<>n) and (o<>n))
then writeln(m,u,h,a,'+',m,u,h,a,'+',m,u,h,a,'=',s,l,o,n);
end.
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.