- 数独验证
- 2017-03-14 16:05:48 @
// vijosP1335.cpp : 定义控制台应用程序的入口点。
//
#include<iostream>
using namespace std;
#define CMP 45
int main()
{
bool flag = true;
int m_iGet[9][9] = { 0 };
int n=0;
cin >> n;
while (n>0)
{
int row[9] = { 0 };
int column[9] = { 0 };
int square[9] = { 0 };
for (int i = 0; i < 9; ++i)
{
for (int j = 0; j < 9; ++j)
{
cin >> m_iGet[i][j];
row[i] += m_iGet[i][j];
column[j] += m_iGet[i][j];
}
}
cin.get();
int k = 0;
for (int i = 0; i < 9; i += 3)
{
for (int j = 0; j < 9; j += 3, ++k)
{
for (int l = 0; l < 3; ++l)
{
for (int i1 = 0; i1 < 3; ++i1)
{
square[k] += m_iGet[i + l][j + i1];
}
}
}
}
for (int i = 0; i < 9; ++i)
{
if (row[i] != CMP || column[i] != CMP || square[i] != CMP)
{
flag = false;
break;
}
}
if (flag)
cout << "Right" << endl;
else
cout << "Wrong" << endl;
--n;
flag = true;
}
return 0;
}
1 条评论
-
doc LV 10 MOD @ 2017-03-15 01:13:50
已重测
- 1