私は9,9の行列を持っていますが、0が見つかったら0を探します。0の位置を保持する11サイズの配列を作成しますiとj)と1-9の数字 がリストに追加され、次の0の追加と削除が検出されます。ループを終了した後にすべてのリスト項目の奇妙なリセット
public static void CheckandCreate()
{
int[] sector = new int[11];
//setting the array to 1-9
for (int i = 2; i < sector.Length; i++)
{
sector[i] = i - 1;
}
//looking for 0
for (int i = 0; i < suduku.GetLength(0); i++)
{
for (int j = 0; j < suduku.GetLength(1); j++)
{
//finding 0
if (suduku[i, j] == 0)
{
sector[0] = i;
sector[1] = j;
sectorlist.Add(sector);
Console.WriteLine("Found Empty on " + i + " " + j);
//check to see array
sectorprinter(sector);
//check to if the array is on list and also print from list(check)
sectorprinter(sectorlist[sectorlist.IndexOf(sector)]);
}
}
//check to see if its still keeps the same value as before,this is where it failes!
Console.WriteLine();
sectorprinter(sectorlist[3]);
Console.WriteLine();
}
Console.WriteLine(sectorlist.Capacity);
Console.WriteLine();
}
コード のthats、これはリストの作成である:私はすべてのセクタ(全配列)を印刷結局
static List<int[]> sectorlist = new List<int[]>();
....
これが出力される。
Found Empty on 0 1
0 1 1 2 3 4 5 6 7 8 9
0 1 1 2 3 4 5 6 7 8 9
Found Empty on 0 2
0 2 1 2 3 4 5 6 7 8 9
0 2 1 2 3 4 5 6 7 8 9
Found Empty on 0 4
0 4 1 2 3 4 5 6 7 8 9
0 4 1 2 3 4 5 6 7 8 9
Found Empty on 0 6
0 6 1 2 3 4 5 6 7 8 9
0 6 1 2 3 4 5 6 7 8 9
Found Empty on 0 7
0 7 1 2 3 4 5 6 7 8 9
0 7 1 2 3 4 5 6 7 8 9
0 7 1 2 3 4 5 6 7 8 9
Found Empty on 1 0
1 0 1 2 3 4 5 6 7 8 9
1 0 1 2 3 4 5 6 7 8 9
Found Empty on 1 1
1 1 1 2 3 4 5 6 7 8 9
1 1 1 2 3 4 5 6 7 8 9
Found Empty on 1 2
1 2 1 2 3 4 5 6 7 8 9
1 2 1 2 3 4 5 6 7 8 9
Found Empty on 1 3
1 3 1 2 3 4 5 6 7 8 9
1 3 1 2 3 4 5 6 7 8 9
Found Empty on 1 4
1 4 1 2 3 4 5 6 7 8 9
1 4 1 2 3 4 5 6 7 8 9
Found Empty on 1 5
1 5 1 2 3 4 5 6 7 8 9
1 5 1 2 3 4 5 6 7 8 9
Found Empty on 1 7
1 7 1 2 3 4 5 6 7 8 9
1 7 1 2 3 4 5 6 7 8 9
Found Empty on 1 8
1 8 1 2 3 4 5 6 7 8 9
1 8 1 2 3 4 5 6 7 8 9
1 8 1 2 3 4 5 6 7 8 9
Found Empty on 2 0
2 0 1 2 3 4 5 6 7 8 9
2 0 1 2 3 4 5 6 7 8 9
Found Empty on 2 2
2 2 1 2 3 4 5 6 7 8 9
2 2 1 2 3 4 5 6 7 8 9
Found Empty on 2 3
2 3 1 2 3 4 5 6 7 8 9
2 3 1 2 3 4 5 6 7 8 9
Found Empty on 2 4
2 4 1 2 3 4 5 6 7 8 9
2 4 1 2 3 4 5 6 7 8 9
Found Empty on 2 5
2 5 1 2 3 4 5 6 7 8 9
2 5 1 2 3 4 5 6 7 8 9
Found Empty on 2 8
2 8 1 2 3 4 5 6 7 8 9
2 8 1 2 3 4 5 6 7 8 9
2 8 1 2 3 4 5 6 7 8 9
Found Empty on 3 1
3 1 1 2 3 4 5 6 7 8 9
3 1 1 2 3 4 5 6 7 8 9
Found Empty on 3 3
3 3 1 2 3 4 5 6 7 8 9
3 3 1 2 3 4 5 6 7 8 9
Found Empty on 3 5
3 5 1 2 3 4 5 6 7 8 9
3 5 1 2 3 4 5 6 7 8 9
Found Empty on 3 8
3 8 1 2 3 4 5 6 7 8 9
3 8 1 2 3 4 5 6 7 8 9
3 8 1 2 3 4 5 6 7 8 9
Found Empty on 4 0
4 0 1 2 3 4 5 6 7 8 9
4 0 1 2 3 4 5 6 7 8 9
Found Empty on 4 1
4 1 1 2 3 4 5 6 7 8 9
4 1 1 2 3 4 5 6 7 8 9
Found Empty on 4 2
4 2 1 2 3 4 5 6 7 8 9
4 2 1 2 3 4 5 6 7 8 9
Found Empty on 4 3
4 3 1 2 3 4 5 6 7 8 9
4 3 1 2 3 4 5 6 7 8 9
Found Empty on 4 5
4 5 1 2 3 4 5 6 7 8 9
4 5 1 2 3 4 5 6 7 8 9
Found Empty on 4 6
4 6 1 2 3 4 5 6 7 8 9
4 6 1 2 3 4 5 6 7 8 9
Found Empty on 4 7
4 7 1 2 3 4 5 6 7 8 9
4 7 1 2 3 4 5 6 7 8 9
Found Empty on 4 8
4 8 1 2 3 4 5 6 7 8 9
4 8 1 2 3 4 5 6 7 8 9
4 8 1 2 3 4 5 6 7 8 9
Found Empty on 5 0
5 0 1 2 3 4 5 6 7 8 9
5 0 1 2 3 4 5 6 7 8 9
Found Empty on 5 3
5 3 1 2 3 4 5 6 7 8 9
5 3 1 2 3 4 5 6 7 8 9
Found Empty on 5 5
5 5 1 2 3 4 5 6 7 8 9
5 5 1 2 3 4 5 6 7 8 9
Found Empty on 5 7
5 7 1 2 3 4 5 6 7 8 9
5 7 1 2 3 4 5 6 7 8 9
5 7 1 2 3 4 5 6 7 8 9
Found Empty on 6 0
6 0 1 2 3 4 5 6 7 8 9
6 0 1 2 3 4 5 6 7 8 9
Found Empty on 6 3
6 3 1 2 3 4 5 6 7 8 9
6 3 1 2 3 4 5 6 7 8 9
Found Empty on 6 4
6 4 1 2 3 4 5 6 7 8 9
6 4 1 2 3 4 5 6 7 8 9
Found Empty on 6 5
6 5 1 2 3 4 5 6 7 8 9
6 5 1 2 3 4 5 6 7 8 9
Found Empty on 6 6
6 6 1 2 3 4 5 6 7 8 9
6 6 1 2 3 4 5 6 7 8 9
Found Empty on 6 8
6 8 1 2 3 4 5 6 7 8 9
6 8 1 2 3 4 5 6 7 8 9
6 8 1 2 3 4 5 6 7 8 9
Found Empty on 7 0
7 0 1 2 3 4 5 6 7 8 9
7 0 1 2 3 4 5 6 7 8 9
Found Empty on 7 1
7 1 1 2 3 4 5 6 7 8 9
7 1 1 2 3 4 5 6 7 8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8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
8 7 1 2 3 4 5 6 7 8 9
Press any key to continue . . .
どうしたのですか?
デバッガでコードをシングルステップ実行しましたか? –
少なくとも、あなたがすでに探求してきたすべての手段を説明し、なぜその誠意を持って取り組んでいるのかまだ分かりません。 – Drakestar