象棋中“车”的攻击范围_C#

如题:

var a = new String[8,8];
            int h, l;
            Console.WriteLine("输入车所在的行(0-7):");
            h = int.Parse(Console.ReadLine());
            Console.WriteLine("输入车所在的列(0-7):");
            l = int.Parse(Console.ReadLine());
            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    a[i,j] = "口";
                }
            }
            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    if (i == h || j == l)
                    {
                        a[i,j] = "杀";
                    }
                }
            }
            a[h,l] = "车";
            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    Console.Write(a[i,j] + "");
                }
                Console.WriteLine();
            }
            Console.ReadKey();

  

猜你喜欢

转载自www.cnblogs.com/wanjinliu/p/10980820.html