//打印出所有的“水仙花数”,“水仙花数”是指一个三位数,其各数字立方和等于该数
#include<stdio.h>
int main() {
int a = 0, b = 0, c = 0, i;
for (i = 100; i < 1000; i++) {
a = i % 10; //个位
b = i / 10 % 10; //十位
c = i / 100 % 10; //百位
if (i == (a * a * a + b * b * b + c * c * c)) {
printf("%d\n", i);
}
}
return 0;
}
11-06
7472
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-26
3858
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交