将123456789填入一下框,不重复

1个回答

  • pascal:

    var

    a,b,c,x1,x2,y1,y2,z1,z2:integer;

    begin

    for a:=1 to 9 do

    for x1:=1 to 9 do begin

    if ax1 then for x2:=1 to 9 do begin

    if (ax2)and(x2x1) then for b:=1 to 9 do begin

    if (ab)and(x1b)and(x2b) then for y1:=1 to 9 do begin

    if (ay1)and(x1y1)and(x2y1)and(by1) then for y2:=1 to 9 do begin

    if (ay2)and(x1y2)and(x2y2)and(by2)and(y1y2) then for c:=1 to 9 do begin

    if (ac)and(x1c)and(x2c)and(bc)and(y1c)and(y2c) then for z1:=1 to 9 do begin

    if (az1)and(x1z1)and(x2z1)and(bz1)and(y1z1)and(y2z1)and(cz1) then for z2:=1 to 9 do begin

    if (az2)and(x1z2)and(x2z2)and(bz2)and(y1z2)and(y2z2)and(cz2)and(z1z2) then

    if ((a/(x1*10+x2))+(b/(y1*10+y2))+(c/(z1*10+z2))=1) then

    writeln('(',a,'/',x1*10+x2,')','+','(',b,'/',y1*10+y2,')','+','(',c,'/',z1*10+z2,')','=',1);

    end;

    end;

    end;

    end;

    end;

    end;

    end;

    end;

    end.

    答案:(5/34)+(7/68)+(9/12)=1