java代码--------编写0懂啊PI之间求随机数的方法

总结:其实每次运行,显示出来的结果个数是随机的。

package com.mmm;

//编写0到PI之间求随机数的方法
public class MEm {
	public static void main(String[] args) {
		double ra = 0.0;
		while (true) {
			if ((ra = Math.random() * 10) < Math.PI) {
				break;// 输出的数是小于圆周率的数
			}
			System.out.println(ra);
		}
	}
}
//
8.628621355139087
5.288658063299242
6.936161128311654

  

原文地址:https://www.cnblogs.com/langlove/p/3497068.html