百钱买百鸡(普通算法)
private void button2_Click(object sender, EventArgs e)
{
int x = 0;
int y = 0;
int z = 0;
for (int i = 1; i < 100; i++)
{
for (int j = 1; j < 100; j++)
{
for (int k = 1; k < 100; k++)
{
if (5 * i + 3 * j + k / 3 == 100 && i + j + k == 100)
{
x = i;
y = j;
z = k;
MessageBox.Show("公鸡: " + x + "只,母鸡: " + y + "只,小鸡: " + z + "只", "算出来了");
}
}
}
}