C\#L 형 바둑판 커버 구현 코드 와 효과

//Main

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChessBoard
{
    class Program
    {
        // , ,
        static void Main(string[] args)
        {
            Function obj = new Function();

            Console.WriteLine("Please intput CheseBoard Size(2^size):");
            int size = (int)Math.Pow(2, Convert.ToInt32(Console.ReadLine()));
            if (size != 1)
            {
                ConsoleColor FC = Console.ForegroundColor;
                //string[] Color = { "Black" , "DarkBlue" , "DarkGreen" , "DarkCyan" , "Gray",
                //                   "DarkRed" , "DarkMagenta" , "DarkYellow" , "Red",
                //                   "DarkGray" , "Blue" , "Green" , "Cyan", "Magenta",
                //                   "Yellow" , "White"};
                string[,] Board = new string[size, size];

                //Do you know ?
                String[] Colors = ConsoleColor.GetNames(typeof(ConsoleColor));

                Console.WriteLine("please input special grid position (row and col):");
                int rows = Convert.ToInt32(Console.ReadLine());
                int cols = Convert.ToInt32(Console.ReadLine());

                obj.CheseBoard(Board, size, rows, cols);

                for (int r = 0; r < Board.GetLength(0); r++)
                {
                    for (int c = 0; c < Board.GetLength(1); c++)
                    {
                        int Value = Convert.ToInt32(Board[r, c].ToString());
                        if (Value > 0)
                        {
                            if (Value > 15)
                            {
                                Value %= 15;
                            }
                            if ((Value %= 15) == 0)
                            {
                                Value += 1;
                            }
                            Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), Colors[Value]);
                        }
                        Console.Write(Board[r, c] + "  ");
                        // Console.ForegroundColor = FC;
                        Console.ResetColor();
                    }
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("Bugs Bug ! ! !");
            }
            Console.ReadKey();
        }
    }
}

//Class
프로그램 실행 결과 캡 처
 

좋은 웹페이지 즐겨찾기