首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 凌波仙子数 两种方法

2013-03-16 
c# 水仙花数 两种方法方法1:using Systemusing System.Collections.Genericusing System.Textnamespace

c# 水仙花数 两种方法

方法1:

using System;using System.Collections.Generic;using System.Text;namespace test{   class Program   {      static void Main(string[] args)      {         int ge, shi, bai;         Console.WriteLine("所有水仙花数是:");         for (int i = 100; i <= 999; i++)         {            ge = i % 10;            shi = i / 10 % 10;            bai = i / 100;            if (ge * ge * ge + shi * shi * shi + bai * bai * bai == i)               Console.Write("  {0}", i);         }         Console.Read();      }   }}


热点排行