博客已持续运行3674天
面朝大海,春暖花开。
进入博客
不要停下脚步哪怕前方没有光
2.22
2017
Day4 循环结构While语句的练习
 
class Test1_While {
	public static void main(String[] args) {
		//求1-100的和
		int sxhh = 0;
		int i = 0;
		while (i <= 100) {
		sxhh = sxhh + i;
		i++;

				System.out.println(sxhh);

		}
		System.out.println(sxhh + "=======================================");
		//统计100-999内水仙花有多少 个
		int ok = 0;
		int a =100;
		while (a<=999) {
			int ge = a % 10;
			int shi = a / 10 % 10;
			int bai = a /10 /10 % 10;
			if (ge*ge*ge+shi*shi*shi+bai*bai*bai == a) {
				ok++;
				System.out.println(ok);
			}
			a++;
		}
		System.out.println("水仙花一共有:" + ok );
	}
}
上一篇
写评论
昵称: 主页: 邮箱:
回到顶部
Powered by 顾羽宸. Written by . 浙icp备87656888号
在路上...     12.98ms