c# { 1 } 1000以内的水仙花数
2012-10-22 16:35
405 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace number { class Program { static void Main(string[] args) { Console.WriteLine("三位数中:"); for (int i = 100; i <= 999; ++i) { if (num(i) == true) { Console.WriteLine("{0}是水仙花数", i); } else { continue; } } Console.ReadKey(); } static bool num(int number) { int d3 = number / 100; int d2 = number % 100 / 10; int d1 = number % 100 % 10; int N = d3 * d3 * d3 + d2 * d2 * d2 + d1 * d1 * d1; if (number == N) { return true; } return false; } } }
实验结果:
上机感言:这是第一次发c#程序,本来想放弃来,但感觉懂点总比不懂好吧,毕竟咱是干程序的,各种语言必须涉猎一些。。。以后还会继续上C#程序的
相关文章推荐
- 求1000以内的水仙花数. 水仙花数是指一个 n 位数,它的每个位上的数字的 n 次幂之和等于它本身。(例如:1^3 + 5^3 + 3^3 = 153)
- 1000以内的水仙花数
- 求1000以内的水仙花数
- 输出100-1000以内的水仙花数
- 1000以内水仙花数(嵌套循环)
- 在100---1000以内所有水仙花数
- C语言求1000以内水仙花数
- 求1000以内的水仙花数
- 1000以内的水仙花数
- 1000以内的水仙花数
- 用C#计算1000以内含1的数字
- 1000以内的水仙花数
- 求1000以内的所有水仙花数
- C# 计算1000以内的水仙花数 abc = a^3 + b^3 + c^3
- 输出100到1000以内的水仙花数
- 用c#语言编写1000以内能整除3的数字
- 输出1000以内的水仙花数
- (java 编写程序)求1000以内的水仙花数.
- 【C语言】输出1--1000以内的水仙花数
- 使用for循环打印输出1000以内的水仙花数