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

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

  

相关文章:

  • 2022-02-08
  • 2021-11-06
  • 2022-01-11
  • 2021-07-25
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
猜你喜欢
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-05-25
相关资源
相似解决方案