gpt4 book ai didi

java - if 语句产生乱码输出

转载 作者:行者123 更新时间:2023-11-29 04:39:38 25 4
gpt4 key购买 nike

<分区>

我有一个 java 作业要求一个代码告诉用户输入一个点(行和列或 x 和 y),程序输出国际象棋骑士的所有可能移动。

package datastructureass1;
import java.util.Scanner;

public class DataStructureAss1 {

public static void main(String[] args) {
Scanner cin = new Scanner (System.in);

int knight[][]= new int [7][7];

System.out.println("Please enter the knight's position starting with rows followed by columns");
int i=cin.nextInt();
int j=cin.nextInt();

i=i+2;
j=j+1;
if (i<=8&&j<=8)

System.out.println( "{"+knight[i]+","+knight[j]+"}");

i= i+2;
j=j-1;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");

i= i-2;
j=j+1;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");
i= i-2;
j=j-1;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");

i= i+1;
j=j+2;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");
i= i+1;
j=j-2;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");
i= i-1;
j=j+2;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");
i= i-1;
j=j-2;
if (i<=8&&j<=8);
System.out.println( "{"+knight[i]+","+knight[j]+"}");

}

}

当我在 netbeans 中运行它时,它会给我这样的输出:

{[I@6ac1abcf,[I@6ac1abcf}

{[I@50f6d9ca,[I@7e54864c}

{[I@6ac1abcf,[I@6ac1abcf}

{[I@5f3d285f,[I@7e54864c}

{[I@7e54864c,[I@2825a5d2}

{[I@6ac1abcf,[I@7e54864c}

{[I@7e54864c,[I@2825a5d2}

这没有意义,我不知道我的代码做错了什么!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com