c#,for穷举,百鸡百钱

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0;
            for (int a = 0; a <= 50;a++ )
            {
                for (int b = 0; b <= 100; b++)
                {
                    for (int c = 0; c <= 200; c++)
                    {

                        if (a + b + c == 100 && 2 * a + b + 0.5 * c == 100)
                        {
                            x++;
                            Console.WriteLine("公鸡" + a + "母鸡" + b + "小鸡" + c);
                        }
                    }
                }
            }
            Console.WriteLine("共有" + x + "种结果");
        }
    }
}

posted @ 2016-02-17 10:51  什么玩楞啊,我叫旺仔  阅读(154)  评论(0编辑  收藏  举报