这个练习题的for循环怎么写

.Net技术 码拜 9年前 (2016-03-04) 900次浏览
这个练习题的for循环怎么写

 string[,] myIntArray2;
            myIntArray2 = new string[,] {
                                          { "兵", "+", "+", "将", "+", "军", "军", "+", "+"},
                                          { "+", "+", "+", "+", " 兵", "+", "+", "+", "+"},
                                          { "兵", "+", "+", "+", "+", "+", "+", "+", "+"},
                                          { "+", "+", "+", "+", "+", "+", "+", "+", "+"},
                                          { "+", "+", "+", "+", "+", "+", "+", "+", "+"},
                                          { "+", "+", "+", "+", "+", "卒", "相", "+", "+"},
                                          { "+", "+", "+", "+", "兵", "+", "+", "+", "+"},
                                          { "炮", "+", "卒", "+", "相", "马", "+", "+", "+"},
                                          { "+", "+", "+", "+", "卒", "+", "+", "+", "+"},
                                          { "+", "+", "+", "+", "+", "+", "炮", "炮", "车"},       
                                         };
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.WriteLine(myIntArray2[i, j]);
                }
            }

这个练习题的for循环怎么写不知道怎么写了,刚学到数组这节

解决方案

20

搞错了,其实没必要EmptyPosition,直接设置ChessPosition,然后初始化数组ChessPosition[,],没设置具体ChessPosition的就是空格位置,x,y本身也没必要,直接依赖二位数组来输出

20

19 行 Console.Write(myIntArray2[i, j]);
21 行 Console.WriteLine(“”);

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明这个练习题的for循环怎么写
喜欢 (0)
[1034331897@qq.com]
分享 (0)