首页 > 编程语言 > 详细

31 Java语言基础循环结构while语句的格式和基本使用

时间:2017-01-22 13:47:46      阅读:185      评论:0      收藏:0      [点我收藏+]

循环结构 while 语句的格式

 

1 class Demo_While{
2     public static void main(String args[]){
3         int x =1;
4         while(x<10){
5             System.out.println(x);
6             x++;
7         }
8     }
9 }

 

计算100 到999的水仙花数

 1 class Demo_While{
 2     public static void main(String args[]){
 3         int count = 0;
 4         int i = 100;
 5         while(i<=999){
 6             int a  = i%10; //取得个位
 7             int b  = i/10%10; //取得十位
 8             int c  = i/100; //取得百位
 9 
10             if(i == a*a*a+b*b*b+c*c*c){
11                 count++;
12             }
13         }
14         
15     }
16 }

 

31 Java语言基础循环结构while语句的格式和基本使用

原文:http://www.cnblogs.com/panw3i/p/6339976.html

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