Number of daffodils
**Case description: **The number of daffodils refers to a 3-digit number, and the sum of the digits to the power of 3 is equal to itself
For example: 1^3 + 5^3+ 3^3 = 153
Please use the do...while statement to find the number of daffodils in all 3 digits
#include<iostream>
using namespace std;
int main()
{
// 1、先打印所有三位数字
int num = 100;
do
{
//2、从所有尚未数字中找到水鲜花数
int a = 0; //个位
int b = 0; //十位
int c = 0; //百位
a = num % 10; //获取数字的个位
b = num / 10 % 10;//获取数字的十位
c = num / 100; //获取数字的百位
if (a*a*a + b * b*b + c * c*c == num) //如果是水鲜花数,才打印
{
cout << num << endl;
}
num++;
} while (num < 1000);
system("pause");
return 0;
}