public class RandomDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* 生成30个,1-100之间的随机数
* int a=
*/
// int a=(int) (Math.random()*100); random() 返回[0-1 之间的数
for(int i=1;i<=30;i++){
System.out.println(Math.random());
System.out.println((int) (Math.random()*100));
System.out.println(Math.floor(11.2)); // floor 是地板
System.out.println(Math.ceil(11.2)); // ceil 天花板的意思
}
}
}
Math中的随机生成30个1-100个整数
于 2019-06-13 22:08:32 首次发布