51,409
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
test4(10, 4, 100.44, 600.44);
}
public static void test4(int x, int y, double a, double b) {
DecimalFormat nf = new DecimalFormat(".##");
double[][] array = new double[x][y];
for(int i = 0; i < array.length; i++) {
for(int j = 0; j < array[0].length; j++) {
double d = Math.random() * Math.abs(a - b);
while(d < Math.min(a, b) || d > Math.max(a, b)) {
d = Math.random() * Math.abs(a - b);
}
array[i][j] = Double.parseDouble(nf.format(d));
}
}
for(int i = 0; i < array.length; i++) {
System.err.println(java.util.Arrays.toString(array[i]));
}
}