c++ 水仙花数
//水仙花数 是一个 三位数 各位数的立方和=该数
//例如:153=1三次方+5三次方+3三次方
#include <iostream>
using namespace std;
int main()
{
int n,a,b,c;
for(n=100;n<1000;n++)
{
a=n/100;
b=n%100/10;
c=n%10;
if(a*a*a+b*b*b+c*c*c==n)
cout<<n<<" is ShuiXianHua number."<<endl;
}
}
153 is ShuiXianHua number.
370 is ShuiXianHua number.
371 is ShuiXianHua number.
407 is ShuiXianHua number.