/**
* @Author: TianZhang
* @Date: 2021/3/8 20:33
* @Description:水仙花数
*/
public class ForDemo02 {
public static void main(String[] args) {
for (int i = 100; i < 1000; i++) {
int a = i % 10;//个位
int b = ((i % 100) / 10);//十位
int c = (i / 100);//百位
/*System.out.println("个位是" + a);
System.out.println("十位是" + b);
System.out.println("百位是" + c);*/
if (a * a * a + b * b * b + c * c * c == i) {
System.out.println("水仙花数" + i);
}
}
}
}
07-06
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交