- 数独验证
- 2016-11-13 20:43:25 @
#include<iostream>
#include<string.h>
using namespace std;
int arr[10][10];
bool legal[25];
bool number[10];
bool judge(){
for (int i = 1; i < 4; i++){
for (int j = 1; j < 4; j++){
memset(number, 0, sizeof(number));
for (int p = (i - 1) * 3 + 1; p <= i * 3; p++){
for (int q = (j - 1) * 3 + 1; q <= j * 3; q++){
if (number[arr[p][q]])
return false;
else
number[arr[p][q]] = true;
}
}
}
}
return true;
}
int main(){
int n;
cin >> n;
for (int k = 0; k < n; k++){
for (int i = 1; i < 10; i++){
for (int j = 1; j < 10; j++){
cin >> arr[i][j];
}
}
legal[k] = judge();
}
for (int i = 0; i < n; i++){
if (legal[i])
cout << "Right"<<endl;
else
cout << "Wrong"<<endl;
}
return 0;
}
2 条评论
-
tico88612 LV 7 @ 2017-09-29 11:39:07
如果測試是
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
-
2016-11-18 12:47:57@
还好
- 1