题解 | #输出水仙花数#
输出水仙花数
https://www.nowcoder.com/practice/dabaf13009ef4d0cbf22302fd6a530a6
#include <iostream>
using namespace std;
int main() {
// write your code here......
int a,b,c;
for(int i = 100; i<1000; i++)
{
a=i/100;//百位数
b=i%100/10;//十位数
c=i%10;//个位数
if(a*a*a+b*b*b+c*c*c==i)
cout<<i<<endl;
}
return 0;
}
水仙花数:一个三位数,其各位数字的立方和等于该数本身

正浩创新EcoFlow公司福利 644人发布