编写程序,在控制台上输出空心菱形,对角距离为6.public class Diamond { public static void main(String[] args) { printHollowRhombus(6); } public static void printHollowRhombus(int size) { if (size % 2 == 0) { size++;// 计算菱形大小 } for (int i = 0; i i + 1; j--) { ... Read More
posted @ 2014-02-09 14:51
源子陌
Views(3129)
Comments(1)
Diggs(0)
编写程序,用while语句计算1+1/2!+1/3!……+1/20!,并在控制泰山输出计算结果。要求1+1/2!+1/3!……+1/20!,其实就是求1+1*1/2+1*1/2*1/3+……+1*1/2*1/3*……*1/20。import java.math.BigDecimal;public class Jiecheng { public static void main(String args[]) { BigDecimal sum = new BigDecimal(0.0); // 和 BigDecimal factorial = new BigDec... Read More
posted @ 2014-02-09 11:52
源子陌
Views(12022)
Comments(0)
Diggs(0)

浙公网安备 33010602011771号