using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace 水仙花数 { class Program { static void Main(string[] args) { //for循环练习题。 //输出100到999之间所有的水仙花数。水仙花数是个位数、十位数、百位数分别的三次方的和恰好等于这个数。
for (int i = 1; i <= 9; i++)//i为百位上的数字。 { for (int n = 0;n <= 9; n++)//n为十位上的数字。 { for (int m = 0; m <= 9; m++)//m为个位上的数字。 { if ((i * 100 + 10 * n + m ) == (i * i * i + n * n * n + m * m * m))//三个的分别的三次方的和等于这个三个数。 { Console.WriteLine("100到999之间的水仙花数为{0}", (i * 100 + 10 * n + m ));