题解 | #掷骰子游戏#

掷骰子游戏

http://www.nowcoder.com/practice/7b543bee3dc14c49a7b340b2e04209ce

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int seed = scanner.nextInt();
            Random random = new Random(seed);
            //使用random.nextInt(int shu)生成随机数
            System.out.println(random.nextInt(6)+1);
            //write your code here......
            

        }
    }

}
全部评论

相关推荐

零零幺零零幺:至少再做一个项目,然后猛投小厂,不然有点难
点赞 评论 收藏
分享
评论
5
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务