求水仙花数

int i, x, y, z;
for (i = 100; i < 1000; i++)
{
    x = i % 10;
    y = i / 10 % 10;
    z = i / 100;
    if (x * x * x + y * y * y + z * z * z == i)
        cout << i << endl;
}
int num = 100;

do
{
    int a = num % 10;        // 个位
    int b = num / 10 % 10;   // 十位
    int c = num / 100;       // 百位

    if (a*a*a + b*b*b + c*c*c == num)
    {
        cout << num << endl;
    }
    
    num++;
}while(num < 1000);
原文地址:https://www.cnblogs.com/shiyixirui/p/15404864.html