本文介绍了这个数独代码出了什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个数独代码,只是试图检查列是否是核心。我稍后会控制行和方块。虽然对我来说似乎是对的。它不起作用。模拟器冻结了。这是代码:
I''ve written a Sudoku code and just tried to check if columns were corect. I will be controlling rows and squares later. Although it seems right to me. It doesn''t work. the simulator freezes. Here is the code:
TextBox[,] dene = new TextBox[9,9];
Random b = new Random();
int kontrol = 0;
int m=0;
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
dene[i, j] = new TextBox();
dene[i, j].Text = "0" ;
}
}
for (int i = 0; i < 9; i++)
{
for (int j=0;j<9;j++)
{
while (m == 0)
{
int inta = b.Next(1, 10);
for (int k = 0; k < 9; k++)
{
int c = Convert.ToInt32(dene[i, k].Text);
if (inta == c)
{
kontrol++;
}
}
if (kontrol == 9)
{
dene[i, j].Text = inta.ToString();
kontrol = 0;
m = 1;
}
else
{
kontrol = 0;
}
}
m = 0;
}
}
推荐答案
if (inta != c)
{
kontrol++;
}
Ty非常
Ty very much
这篇关于这个数独代码出了什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!