首页 > 编程语言 > 详细

用c#语言编写水仙花数

时间:2018-04-09 19:58:07      阅读:194      评论:0      收藏:0      [点我收藏+]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
  {
          class Program
           {
                  static void Main(string[] args)
                   {
                         for (int i = 100; i < 999; i++)
                         {
                                 int a = i / 100 % 10;
                                 int b = i / 10 % 10;
                                 int c = i / 10;
                                 if (a * a * a + b * b * b + c * c * c ==i)
                                 {
                                     Console.WriteLine(i);
                                  }

                          }
               }
      }
}

用c#语言编写水仙花数

原文:https://www.cnblogs.com/yangkaiming/p/8762211.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!