2. 如何产生一个随机的整数i,使得0 <= i <= 50?3. 编写一个表达式,随机返回0或者1。 相关知识点: 试题来源: 解析 int i = (int)(Math.random() * 10) + 10;int i = (int)(Math.random() * 51);int i = (int)(Math.random() * 2); ...
public static void main(String[] args) { int arr[] = new int[11]; // 创建一个长度为11的整数数组 Random r = new Random(); // 创建一个随机数生成器 // 生成10个0~100的随机整数并存储在数组中 for (int i = 0; i < 10; i++) { arr[i] = r.nextInt(100) + 1; ...