using System;
class Anysis
{
static void Main()
{
int[] var1 = new int[3];
int total;
int i, j, k;
Console.WriteLine("Enter a value which less than thousand:");
total = Convert.ToInt32(Console.ReadLine());
int index = 0;
int var2 = total;
while (var2 != 0)
//分解出这位数字 个、十,百
{
var1[index] = var2 % 10;
var2 = var2 / 10;
index++;
}
i = var1[0] * var1[0] * var1[0];
j = var1[1] * var1[1] * var1[1];
k = var1[2] * var1[2] * var1[2];
if ((i + j + k) == total)
Console.WriteLine("{0} 是水仙花数", total);
else
Console.WriteLine("No");
Console.ReadKey();
}
}
。。好像这样了