水仙花数:是一个三位数,百位数的3次方加十位数的3次方加个位数的3次方等于这个数;例如
153:1*1*1+5*5*5+3*3*3=153
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 label1_Click(object sender, EventArgs e)
{
for (int i=100;i<1000; i++)
{
int a = i / 100;
int b = i % 100;
int c = b / 10;
int d = b % 10;
if (a*a*a+c*c*c+d*d*d==i)
{
label1.Text += i+",";
}
}
}
}
}