【发布时间】:2022-08-07 18:45:27
【问题描述】:
我的数独有问题。我必须检查是否有效。我卡在检查线和行,我不知道该怎么做。
这是我的代码。
static int[] ReadValues()
{
string[] line = Console.ReadLine().Split(\' \');
int[] array = Array.ConvertAll(line, int.Parse);
return array;
}
static int[,] CreateMatrix()
{
const int matrixSize = 9;
int[,] sudoku= new int[matrixSize, matrixSize];
for (int i = 0; i < matrixSize; i++)
{
int[] array = ReadValues();
for (int j = 0; j < matrixSize; j++)
{
sudoku[i, j] = array[j];
}
}
return sudoku;
}
static bool CheckLine(int[,] sudoku)
{
// this is the method where I\'m stuck
}
static bool CheckRow(int[,] sudoku)
{
// this is the method where I\'m stuck
}
-
不是真的,我必须检查行/行中的数字是否重复。
-
一个快速的谷歌会给你很多想法。
标签: c#