class Test3_Flower {
public static void main(String[] args) {
int huas = 0;
for (int i = 100;i <= 999 ;i++ ) { //获取100到999之间的数
int ge = i % 10; //123 % 10
int shi = i /10 % 10; //12 % 10
int bai = i /10 / 10 %10; // 1 % 10
if (ge * ge * ge + shi * shi * shi + bai* bai *bai == i ) {
System.out.println(i);
huas = huas + 1 ;
}
}
System.out.println("水仙花数有" + huas);
System.out.println("Hello World!");
}
}
Day4 笔记 循环结构For语句的练习之统计思想(计数器)
- admin
- 0