(一)题目描述
打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身。例如:153是一个水仙花数,因为153=13+53+3^3。 Output:
153
???
???
???
输入
无
输出
所有的水仙花数,从小的开始。每行一个
(二)代码
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
for (int k = 0; k <= 9; k++)
{
if (i * 100 + j * 10 + k == i * i * i + j * j * j + k * k * k)
{
if (i * 100 + j * 10 + k != 1 && i * 100 + j * 10 + k != 0)
{
Console.WriteLine(i * 100 + j * 10 + k);
}
}
}
}
}
}
}
}