判断是否为水仙花数:
args:
int d = Convert.ToInt32(Console.ReadLine());
int a, b, c;
a = d % 1000/100;//baiwei
b = d %100/10;//shiwei
c = d % 100 % 10;//gewei
if (d == a * a * a + b * b * b + c * c * c)
{
Console.WriteLine("这个是水仙花数" + d);
}
else
{
Console.WriteLine("这个不是水仙花数");
}
goto args;
求水仙花数:
//int e = 0;
//for (int i = 100; i < 1000; i++)
//{
// int a = i / 100 ;
// int b = i / 100 % 10;
// int c = i % 10;
// if (i == a * a * a + b * b * b + c * c * c )
// {
e++;
// Console.WriteLine(i);
// }
//}
Console.WriteLine(e);