小编Ell*_*lla的帖子

如何将一个String附加到一个int数组?

我已经在这个网站上做了一些关于这方面的研究,但是,我在寻找可以使用的东西时遇到了一些麻烦.我正在尝试为口袋妖怪创建一个类似的程序,但更简单和基于文本.目前我正在使用数组存储Pokemon的统计数据.这工作得很好,但是当我需要打印Pokemon的名字时,我必须手动输入它.这个工作得很好,但我想让玩家与一个随机的口袋妖怪战斗.这是我目前的代码:

public static void main(String[] args) {
    //Declare the Pokemon to be used
    int[] Player    = {0,  0,  0,   0,  0,   0  };
    int[] Blastoise = {79, 83, 100, 85, 105, 78 };
    int[] Raichu    = {60, 90, 55,  90, 80,  110};
    int[][] Pokemon = new int[][] {Blastoise, Raichu, Player};

    Scanner input = new Scanner(System.in);

    startBattle(input, Pokemon)
}
public static String startBattle(Scanner input, int[][] Pokemon) {
        System.out.println("A wild Pokemon appeared!");
        int r = (int) (Math.random() * 1);
        System.out.println("A wild " …
Run Code Online (Sandbox Code Playgroud)

java arrays int

3
推荐指数
1
解决办法
164
查看次数

JL在at&t语法中是什么意思?

我正在为一个学校项目工作,我JL在at&t语法中找不到任何含义。供参考,问题是找到运行%eax时的值NOP。这是它使用的代码:

MOV $492,%ebx
MOV $2494,%eax
MOV $28063,%ecx
CMP %eax,%ebx
JL L1
JMP L2
L1:
IMUL %eax,%ebx
ADD %eax,%ebx
MOV %ebx,%eax
SUB %ecx,%eax
JMP L3
L2:
IMUL %eax,%ebx
SUB %eax,%ebx
MOV %ebx,%eax
ADD %ecx,%eax
L3:
NOP
Run Code Online (Sandbox Code Playgroud)

另外,我还要感谢JMP加法/减法/乘法的工作方式(ADD/ SUB/ IMUL)。我不想作弊,我只是想了解发生了什么。例如,您在使用数学时会更改第一个数字还是第二个数字?非常感谢大家的帮助。

att

1
推荐指数
1
解决办法
1993
查看次数

标签 统计

arrays ×1

att ×1

int ×1

java ×1