标签:
static void Main(string[] args) //记住格式
{
int n = 0;
for (int x = 1; x * 2 <= 100; x++)
{
for (int y = 1; y * 1 <= 100; y++)
{
for (int z = 1; z * 0.5 <= 100; z++)
{
if (x*2+y*1+z*0.5==100&&x+y+z==100)
{
System.Threading.Thread.Sleep(300);
Console.WriteLine(x+"只公鸡 "+y+"只母鸡 "+z+"只小鸡 "+"一共"+(x+y+z)+"只鸡");
n++;
}
}
}
}
Console.Write("共有"+n+"种可能性");
Console.ReadLine();
}
标签:
原文地址:http://www.cnblogs.com/Mr-xue/p/4423138.html