using System;
using System.Collections.Generic;
using System.Text;
namespace KnowledgePoint
{
class _17_Ex_For
{
static void Main(string[] args)
{
// 正向for循环:编辑器输入for后再按两下Tab键补齐代码
// 逆向for循环:编辑器输入forr后再按两下Tab键补齐代码
for (int i = 100; i <= 999; i++)
{
int unit = i % 10;
int ten = i / 10 % 10;
int hundred = i / 100 % 10;
if (unit * unit * unit + ten * ten * ten + hundred * hundred * hundred == i)
{
Console.WriteLine("水仙花数 - " + i);
}
}
Console.ReadKey();
}
}
}
C#输出100~999之间的水仙花数
最新推荐文章于 2024-03-16 10:39:29 发布