本文由搞代码网为大家展示了《java解决珠穆朗玛峰折纸问题》的代码案例,请各位coder不吝赐教,也欢迎coder点赞收藏转发,感谢
public class 珠穆朗玛峰折纸 { public static void main(String[] args) { double paper = 0.01; double height = 8848; int count = 0; while (true) { paper = paper * 2; count++; if (paper > height) { break; } } System.out.println("一共折叠了" + count + "次,目前纸张这么高" + paper); } }