C#趣味程序---百鸡百钱

问题:公鸡一仅仅5元,母鸡一仅仅3元,小鸡三仅仅1元。问100元能够买多少仅仅鸡?

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int z, i=0;
            for (int x = 0; x < 20; x++)
                for (int y = 0; y < 33; y++)
                {
                    z = 100 - x - y;
                    if (5 * x + 3 * y + z / 3 == 100 && z % 3 == 0)
                        Console.WriteLine("{0}.公鸡:{1}"+'	'+"母鸡:{2}"+'	'+"小鸡:{3}",++i,x,y,z);
                }
            Console.ReadLine();
        }
    }
}


原文地址:https://www.cnblogs.com/yxysuanfa/p/6909226.html