1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| uses wincrt;
var
ch1,ch2,ch3,ch4,ch:string;
j,x1,x2,x3,x4,e1,e2,e3,e4,n,i:integer;
begin
n:=1000;
repeat
n:=n+1;
i:=1;
str(n,ch);
repeat
if i=1 then
begin
ch1:=copy(ch,1,3);
i:=i+3;
end;
if i=3 then
begin
ch3:=copy(ch,i,2)+ch[1];
i:=i-1;
end;
if i=4 then
begin
ch4:=ch[4]+copy(ch,1,2);
i:=i-1;
end;
if i=2 then
begin
ch2:=copy(ch,i,3);
end;
until i=2;
val(ch1,x1,e1); val(ch2,x2,e2);val(ch3,x3,e3);val(ch4,x4,e4);
if n=x1+x2+x3+x4 then
writeln(n,' = ',x1,' + ',x4,' + ',x3,' + ',x2);
until n=9999;
write(' ok ');
end. |
Partager