Пример #1
0
 /// <summary>
 /// クイーンの位置を仮決めして探索スタート
 /// </summary>
 static Board SearchBoardPosition(int x, int y)
 {
     Board aBoard = new Board(x, y);
     for (int i = 0; i < N; i++)
     {
         for (int j = 0; j < N; j++)
         {
             aBoard.UpdateBoard(i, j);
         }
     }
     return aBoard;
 }
Пример #2
0
        static void Main(string[] args)
        {
            Board MaxSolvedBoard = new Board(0,0);
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    var aBoard = SearchBoardPosition(i, j);
                    if (MaxSolvedBoard.NumOfQueen < aBoard.NumOfQueen)
                    {
                        MaxSolvedBoard = aBoard;
                    }
                    Console.Out.Write(".");
                }
                Console.Out.WriteLine("");
            }

            Console.Out.WriteLine("");
            Console.Out.WriteLine("solved num:{0}", MaxSolvedBoard.NumOfQueen);

            //配置の出力
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (MaxSolvedBoard.xy[i, j])
                        Console.Out.Write("Q");
                    else
                        Console.Out.Write(".");
                }
                Console.Out.WriteLine("");
            }
        }