赞
踩
package day4.work; public class WorkDay04_01 { public static void main(String[] args){ //定义珠峰高度 int zf = 8848; //定义折叠次数 int zdcs = 1 ; //定义纸张厚度 double zzhd = 0.01; while (zzhd<=zf){ zzhd =(double)(zzhd *2); zdcs++; } if (zzhd>zf){ //因为while执行条件(zzhd<=zf)不满足时循环跳出,但是zdcs已经多+1所以结果需要-1 System.out.println("最少折叠次数是:"+(zdcs-1)); }else{ zdcs+=1; System.out.println("最少折叠次数是:"+zdcs); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。