JAVA(课后练习)部分拓展实践代码.docVIP

  • 19
  • 0
  • 约1.22万字
  • 约 14页
  • 2019-09-08 发布于浙江
  • 举报
Chap 2 实践2-1 class Ex2_1{ public static void main(String[] args) { float sum=0.0f,count=1.0f; for(int i=1;i=20;++i){ count=1.0f; for(int j=1;j=i;++j) count*=j; sum+=count; } System.out.println(1+2!+3!+...+20!的值为:+sum); } } 实践2-2 public class Ex2_2{ public static void main(String[] args) { System.out.println(** 菲波拉挈数列的前20个数为:**); long f1 = 1, f2 = 1; for (int i = 1; i = 10; i ++) { System.out.print(f1 + + f2 + ); if (i % 2 == 0) { System.out.println(); } f1 = f1 + f2; f2 = f2 + f1; }

文档评论(0)

1亿VIP精品文档

相关文档