随机数类型:整数
随机数范围:low~high
生成方法:Math.random
public class Random {
public int [] RandomGen(int n, int low, int high)
{
int[]r = new int[n];
int diff=high-low;
for(int i=0;i<n;i++)
{
r[i]=(int)(Math.random()*diff)+low;
}
return r;
}
}
主函数:
public static void main(String[] args) {
int N=1000;
int start = 0;
int end = 100000;
Random rn =new Random();
int[] A = new int[N];
A = rn.RandomGen(N, start, end);//生成0到100000内的100个随机数