首页 > 其他 > 详细

while and for 2

时间:2017-09-28 22:13:54      阅读:235      评论:0      收藏:0      [点我收藏+]
 1 public class TestWhileAndFor2 {
 2 
 3     /**
 4      * 九九乘法表
 5      * 1!+2!+3!+....+10!=?
 6      *  
 7      */
 8     public static void main(String[] args) {
 9         /*
10         for(int i=1;i<=9;i++){
11             for(int j=1;j<=i;j++){
12                 System.out.print(j+"*"+i+"="+(j*i)+"\t");
13                 }
14             System.out.println();
15         }
16         */
17         //1!+2!+3!+....+10!=?
18         long sum=1;
19         long total=0;
20         for(int j=1;j<=10;j++){
21             sum=sum*j;
22             total+=sum;
23             System.out.println(j+"!="+sum);
24         }
25         
26         System.out.println(" 1!+2!+3!+....+10!="+total);
27         
28         //1+2+3..+10=?
29         long count=0;
30         for(int i=1;i<=10;i++){
31             count+=i;
32         }
33         System.out.println(count);
34     }
35     
36 
37 }

 

while and for 2

原文:http://www.cnblogs.com/PoeticalJustice/p/7608788.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!