小编Hal*_*alo的帖子

猜测用户用java(数组)思考的数字

我对编程很陌生,我们的老师要求我们制作一个能够猜出用户使用数组思考的数字的程序.我这样做了:

import java.util.Scanner;

public class Exercise11 {

    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        System.out.println("Think a number between 1 and 100");
        int array[] = new int[100];

        for (int x = 0; x < 100; x++) {
            array[x] = (int) ((Math.random() * 100) + 1);
        }
        //This allow us to fill the array with random numbers, without caring if they are repeated or not.
        for (int i = 0; i < 100; i++) {
            for (int j …
Run Code Online (Sandbox Code Playgroud)

java arrays for-loop

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

标签 统计

arrays ×1

for-loop ×1

java ×1