111,129
社区成员
发帖
与我相关
我的任务
分享
string[,] myIntArray2;
myIntArray2 = new string[,] {
{ "兵", "+", "+", "将", "+", "军", "军", "+", "+"},
{ "+", "+", "+", "+", " 兵", "+", "+", "+", "+"},
{ "兵", "+", "+", "+", "+", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "卒", "相", "+", "+"},
{ "+", "+", "+", "+", "兵", "+", "+", "+", "+"},
{ "炮", "+", "卒", "+", "相", "马", "+", "+", "+"},
{ "+", "+", "+", "+", "卒", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "+", "炮", "炮", "车"},
};
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 10; j++)
{
Console.WriteLine(myIntArray2[i, j]);
}
}
不知道怎么写了,刚学到数组这节 class Program
{
static void Main(string[] args)
{
string[,] myIntArray2;
myIntArray2 = new string[,] {
{ "兵", "+", "+", "将", "+", "军", "军", "+", "+"},
{ "+", "+", "+", "+", " 兵", "+", "+", "+", "+"},
{ "兵", "+", "+", "+", "+", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "卒", "相", "+", "+"},
{ "+", "+", "+", "+", "兵", "+", "+", "+", "+"},
{ "炮", "+", "卒", "+", "相", "马", "+", "+", "+"},
{ "+", "+", "+", "+", "卒", "+", "+", "+", "+"},
{ "+", "+", "+", "+", "+", "+", "炮", "炮", "车"},
};
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 9; j++)
{
Console.Write(myIntArray2[i, j]);
}
Console.WriteLine("");
}
Console.ReadKey();
}
}
好了,谢谢大神们帮解答~
class EmptyPosition
{
public int X{ get;set;}
public int Y {get;set;}
}
class ChessPosition:EmptyPosition
{
public int Text{get;set;}
public Color Color {get;set;}
}
EmptyPosition[,] positions = new EmptyPosition[10,9];
//xxxx
当然你也可以Empty和正常的棋子没区别,都具备Text和Color属性,这样输出时就少个判断棋子类型的过程