1234567891011121314151617181920212223242526272829303132333435 |
- /**
- * ClassName: Test02
- *
- * @Author 爱扣钉-陈晨
- * @Create 2023/11/4 10:40
- * @Version 1.0
- */
- public class Test02 {
- public static void main(String[] args) {
- //随机数
- double random = Math.random();
- //0-1 小数数字
- System.out.println(random);
- //0 - 100
- double v = random * 100;
- System.out.println(v);
- //转换
- int i = (int) v;
- System.out.println(i);
- // 50 - 100
- // 0-50 + 50 ;
- int i1 = (int) (Math.random() * 50) + 50; // 0-49
- System.out.println(i1);
- // a - b;
- // (int) (Math.random() * a - b) + a
- }
- }
|