二维数组_象棋中“车”的攻击范围_Java
作者:
万金流 | 来源:发表于
2019-05-29 09:33 被阅读0次String[][] a = new String[8][8];
int h, l;
Scanner scan = new Scanner(System.in);
System.out.println("输入车所在的行(0-7):");
h = scan.nextInt();
System.out.println("输入车所在的列(0-7):");
l = scan.nextInt();
for (int i = 0; i < a.length; i++)
{
for (int j = 0; j < a[i].length; j++)
{
a[i][j] = "口";
}
}
for (int i = 0; i < a.length; i++)
{
for (int j = 0; j < a[i].length; j++)
{
if (i == h || j == l)
{
a[i][j] = "杀";
}
}
}
a[h][l]="车";
for(int i=0;i<a.length;i++)
{
for(int j=0;j<a[i].length;j++)
{
System.out.print(a[i][j]+" ");
}
System.out.println();
}
本文标题:二维数组_象棋中“车”的攻击范围_Java
本文链接:https://www.haomeiwen.com/subject/deqetctx.html
网友评论