- 数独验证
- 2016-04-04 13:10:04 @
var a,b:array[1..9,1..9] of longint;
c:array[1..10000] of string;
i,sum2,j,k,l,n,m,o,q,sum1,sum,p:longint;
begin
readln(n);
for i:=1 to n do
begin
for j:=1 to 9 do
for k:=1 to 9 do
read(a[j,k]);
readln;
for l:=1 to 9 do
sum:=sum+a[l,1];
for l:=1 to 9 do
begin
for m:=1 to 9 do
sum1:=sum1+a[l,m];
if sum1<>sum then
c[i]:='WRONG';
sum1:=0;
end;
for q:=1 to 9 do
begin
for o:=1 to 9 do
sum1:=sum1+a[o,q];
if sum1<>sum then
c[i]:='WRONG';
sum1:=0;
end;
for j:=1 to 9 do
for k:=2 to 9 do
if a[j,k]=a[j,1] then
c[i]:='WRONG';
while k<=7 do
begin
while j<=7 do
begin
sum2:=a[k,j]+a[k+1,j]+a[k+2,j]+a[k,j+1]+a[k+1,j+1]+a[k+2,j+1]+a[k,j+2]+a[k+1,j+2]+a[k+2,j+2];
if sum2<>45 then
c[i]:='WRONG';
sum2:=0;
j:=j+3;
end;
k:=k+3;
j:=1;
end;
end;
for p:=1 to n do
if c[p]='WRONG' then
writeln('Wrong')
else writeln('Right');
end.
1 条评论
-
贱人在我右边 LV 9 @ 2016-11-18 12:48:49
还好
- 1