[1。。9,1。。9]ofchar;b:array[1。。81,1。。2]ofinteger;i,j,c,s,area,k,l:integer;{c:thenumberofspaces。}x:char;Beginwriteln('Pleaseinputthe9*9square(Youcaninput"*"atanytimeifyouwanttoexit):');fori:=1to9dobeginforj:=1to9dobeginread(a[i,j]);ifa[i,j]=''thenbeginc:=c+1;b[c,1]:=i;b[c,2]:=j;endelseifa[i,j]='*'thenbeginwriteln('Exit。
。。');exitend;end;readln;end;s:=1;Writeln('Pleasestandby。。。
');i:=0;j:=0;Whiles>0dobeginif(i=b[c,1])and(j=b[c,2])thenbeginwriteln;fori:=1to9dobeginforj:=1to9dowrite(a[i,j]);writeln;end;a[i,j]:='';s:=s-1;i:=b[s,1];j:=b[s,2];exit;end;{findasolution}i:=b[s,1];j:=b[s,2];if((i>=1)and(i=1)and(j=4)and(i=1)and(j=7)and(i=1)and(j=1)and(i=4)and(j=4)and(i=4)and(j=7)and(i=4)and(j=1)and(i=7)and(j=4)and(i=7)and(ji)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=false;end;ifarea=2thenbeginfork:=4to6doforl:=1to3doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=3thenbeginfork:=7to9doforl:=1to3doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=4thenbeginfork:=1to3doforl:=4to6doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=5thenbeginfork:=4to6doforl:=4to6doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=6thenbeginfork:=7to9doforl:=4to6doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=7thenbeginfork:=1to3doforl:=7to9doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=8thenbeginfork:=4to6doforl:=7to9doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifarea=9thenbeginfork:=7to9doforl:=7to9doif(x=a[k,l])and((k<>i)or(l<>j))thencan:=false;fork:=1to9doif((x=a[i,k])and(k<>j))or((x=a[k,j])and(k<>i))thencan:=falseend;ifcanthenbreakelseif(x<>'9')thencan:=true;end;ifcanthenbegina[i,j]:=x;s:=s+1;endelsebegina[i,j]:='';s:=s-1;end;end;end。
全部