您当前的位置: 首页 >  c#

刘一哥GIS

暂无认证

  • 6浏览

    0关注

    934博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C#趣味程序---水仙花数

刘一哥GIS 发布时间:2015-06-09 12:06:07 ,浏览量:6

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 水仙花数
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int a = 0, b = 0, c = 0;
            for (int i = 100; i < 1000; i++)
            {
                a = i / 100;
                Math.DivRem(i, 100, out b);
                b = b / 10;
                Math.DivRem(i, 10, out c);
                a = a * a * a;
                b = b * b * b;
                c = c * c * c;
                if ((a + b + c) == i)
                    listBox1.Items.Add(i.ToString());
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
关注
打赏
1665586602
查看更多评论
立即登录/注册

微信扫码登录

0.0739s