思路分析:
1. x、y、z的取值范围为0~100
2. x+y+z==100(鸡的总数为100)
3. 5*x+3*y+z/3==100(钱的总数为100)
4. z%3==0(小鸡只数是3的整数倍)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace buyChicken
{
class Program
{
static void Main(string[] args)
{
int x, y, z;
for (x = 0; x <= 100; x++)
{
for (y = 0; y <= 100; y++)
{
for (z = 0; z <= 100; z++)
{
if ((5 * x + 3 * y + z / 3 == 100) && (x + y + z == 100) && (z % 3 == 0))
{
Console.Write("公鸡{0},母鸡{1},小鸡{2}\n", x, y, z);
}
}
}
}
Console.ReadKey();
}
}
}