请问怎么随机数老是全0???? 而且引入的 import java.Math.*;他提示没用到??import java.math.*;
public class bubble_sort {
public static void main(String[] args) {
for(int x=0; x<10; x++)
System.out.print((int)(Math.random())+ " ");
}
}
public class bubble_sort {
public static void main(String[] args) {
for(int x=0; x<10; x++)
System.out.print((int)(Math.random())+ " ");
}
}
java.lang.Mathstatic double random()
Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. 产生的是 《1 and 》0的小数
强制转换(int)(Math.random())当然是0啦
public class bubble_sort {
public static void main(String[] args) {
for(int x=0; x<10; x++)
int i=(int)(Math.random()*8)+1;
System.out.printl(" "+i);
}
}
从8到1的整数!