水仙花数是指一个3位数,它的每个位上的数字的3次幂之和等于他本身的数
如:1^3 + 5^3 + 3^3 = 153
#include<iostream>
using namespace std;
int main()
{
int i;
int b, c, d;
i = 100;
do
{
b = i % 10;//个位数
c = (i/10)%10;//十位数
d = i / 100;//百位数
if (b*b*b + c*c*c + d*d*d == i)
{
cout << i << endl;
}
i++;
} while (i<1000);
system("pause");
return 0;
}