判断语句好烦,最后改用深搜
查看原帖
判断语句好烦,最后改用深搜
5125
dddttdLGOJ楼主2014/11/22 14:04
program p1008;
var b:array[1..10000]of integer;
    l,a,c,d,i,bj:integer;
    bb,bd:boolean;
begin
  l:=0;bb:=true;
  while bb do
  begin
    l:=l+1;b[l]:=0;bd:=true;
    while bd do
    begin
      b[l]:=b[l]+1;
      if b[l]<=9 then
      begin
        bj:=0;
        for i:=1 to l-1 do
        if b[l]=b[i] then
        begin
          bj:=1;
          break;
        end;
        if bj=0 then
        if l=9 then
        begin
          a:=b[1]*100+b[2]*10+b[3];
          c:=b[4]*100+b[5]*10+b[6];
          d:=b[7]*100+b[8]*10+b[9];
          if (a/1=c/2)and(c/2=d/3) then
          writeln(a,' ',c,' ',d);
        end
        else bd:=false;
      end
      else 
      begin
        l:=l-1;
        if l<1 then
        begin
          bd:=false;
          bb:=bd;
        end;
      end;
    end;
  end;
end.
2014/11/22 14:04
加载中...