设计界面
编写代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace c
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int a = 0;
int b = 0;
int c = 0;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
label2.Text = "";
int x;
for (x = 100; x <= 999; x++)
{
a = x % 10;
b = x / 10 % 10;
c = x / 100;
if (a * a * a + b * b * b + c * c * c == x)
{
label2.Text += "\n\n\n" + string.Format("{0}^3 + {1}^3 + {2}^3 = {3}", a, b, c, x);
}
}
}
}
}
运行结果