- 数独验证
- 2016-08-22 18:23:28 @
var
i,j,k,n:longint;
a:array[1..9,1..9]of longint;
function power:boolean;
var
b,x,y:longint;
begin
power:=true;
for b:=1 to 9 do
for x:=1 to 8 do
for y:=x+1 to 9 do
begin
if a[x,b]=a[y,b] then
begin
exit(false); break;
end;
if a[b,x]=a[b,y] then
begin
exit(false); break;
end;
end;
end;
function fun:boolean;
var
c,d:longint;
m,n:array[1..3]of longint;
begin
fun:=true;
m[1]:=2;m[2]:=5;m[3]:=8;n[1]:=2;n[2]:=5;n[3]:=8;
for c:=1 to 3 do
for d:=1 to 3 do
begin
if (a[m[c],n[d]]=a[m[c]-1,n[d]-1])
or (a[m[c],n[d]]=a[m[c]+1,n[d]-1])
or (a[m[c],n[d]]=a[m[c]-1,n[d]+1])
or(a[m[c],n[d]]=a[m[c]+1,n[d]+1]) then
begin
exit(false); break;
end;
if (a[m[c]-1,n[d]]=a[m[c],n[d]-1])
or (a[m[c]-1,n[d]]=a[m[c],n[d]+1])
or (a[m[c]+1,n[d]]=a[m[c],n[d]+1])
or(a[m[c]+1,n[d]]=a[m[c],n[d]-1])
or (a[m[c]-1,n[d]]=a[m[c]+1,n[d]])
or (a[m[c],n[d]-1]=a[m[c],n[d]+1]) then
begin
exit(false); break;
end;
end;
end;
begin
readln(n);
for i:=1 to n do
begin
for j:=1 to 9 do
begin
for k:=1 to 9 do
read(a[j,k]);
readln;
end;
if not power then writeln('Wrong')
else if not fun then writeln('Wrong')
else writeln('Right');
fillchar(a,sizeof(a),0);end;
end.
4 条评论
-
贱人在我右边 LV 9 @ 2016-11-18 11:04:31
谁给我一个c++
-
2016-11-18 11:04:20@
就是,过了就行
-
2016-11-07 21:51:36@
过了就行
-
2016-08-22 19:33:32@
还行
- 1