水仙花数,也被称为超完全数字不变数,是指一个3位数,他的每个数位上的数字的3次幂之和等于他自身。
C#实现
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace water_flowers
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("水仙花数为:");
for(int i = 100; i <= 999; i++)
{
int a = i % 10;
int b = (i / 10) % 10;
int c = (i / 100) % 10;
if (i == a * a * a + b * b * b + c * c * c)
{
Console.Write(i);
Console.ReadLine();
}
}
}
}
}