回 帖 发 新 帖 刷新版面

主题:sudoku checking><``plz help!

fill[x,y] 储存哪几个格输入了数字的array(boolean)
row[x,num] 储存一横行中哪几个数字出现了的array(boolean)
column[y,num]储存一直行中哪几个数字出现了的array(boolean)
square[i,num]储存一9宫格中哪几个数字出现了的array(boolean)


先用第3段的code 在txt file load入数据,,,
再读入数字,,用第2段code,,赋值予array
然后用第1段code检查,,
但结果不行>


procedure checking;
     begin
          finish:= true;
          i:=1;j:=1;
          repeat
          if not(fill[i,j]) then finish:=false;
          if not(row[i,j]) then finish:=false;
          if not(column[j,i]) then finish:=false;
          if not(square[i,j]) then finish:=false;
          if j=9
          then begin
               j:=1;
               i:=i+1;
               end
          else j:=j+1;
          until (not(finish)) or ((i=10)and(j=1));
          if not(finish) then halt;

     end;
.
.
.
.
.
game[x,y]:=key;
     fill[x,y]:=true;
     val(key,inputnum,error);
     row[x,inputnum]:=true;
     column[y,inputnum]:=true;
     square[i,inputnum]:=true;
.
.
.
.
game[y,z]:=num;
                    fill[y,z]:=true;
                    val(num,loadnum,error);
                    row[y,loadnum]:=true;
                    column[z,loadnum]:=true;
                    case y of
                         1..3 : case z of
                                1..3 : i:=1;
                                4..6 : i:=2;
                                7..9 : i:=3;
                                end;
                         4..6 : case z of
                                1..3 : i:=4;
                                4..6 : i:=5;
                                7..9 : i:=6;
                                end;
                         7..9 : case z of
                                1..3 : i:=7;
                                4..6 : i:=8;
                                7..9 : i:=9;
                                end;

                         end;
                        square[i,loadnum]:=true;

回复列表 (共1个回复)

沙发

什么意思?
请说清题目,谢谢!

我来回复

您尚未登录,请登录后再回复。点此登录或注册