然后将其转换为接受 1 - 100 的随机整数。我有点不知所措。我到目前为止是这样的: //Create random number 0 - 99 double randNumber = Math.random(); d = randNumber * 100; //Type cast double to int int randomInt = (int)d; 然而,random double 的挥之不去的问题是 0 是可能的,而 100 ...
public class random { public static void main(String args[]){int i;int a[]=new int[10];for (i=0;i<10;i++)a[i]=(int)(Math.random()*100);for (i=0;i<10;i++)if (a[i]%2==0)System.out.println(a[i]+"是偶数");else System.out.println(a[i]+"是奇数");} ...
Random r=newRandom();int randomInt=r.nextInt(100)+1;