public class RandomTest { public static void main(String[] args) { for (int i = 0; i < 10; i++) { double r = Math.random(); int a = (int) Math.round(r*10); int x=-5,y=15; int n= (int)Math.round(Math.random()*(y-x)+x); // System.out.println("n = " + n); //Random类 Random random =new Random(); n = random.nextInt(5); System.out.println(" n = " + n); } } }
随机数整数的算法
最新推荐文章于 2024-09-11 21:29:29 发布