所谓水仙花数,指的是一个三位整数,其各位数字之立方和等于数字本身
例如:153 = 111 + 555 + 333
本例的核心问题在于对数位的提取,用最基础的数学思想,提取出对应位上的数字,要有严密的数学逻辑
using System;
namespace dome
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("水仙花数:");
for (int i = 100; i < 1000; i++)
{
int g = i % 10;
int s = i / 10 % 10;
int b = i / 100 % 10;
if (g*g*g+s*s*s+b*b*b==i)
{
Console.WriteLine(i);
}
}
}
}
}