如:一只大鸡3元,小鸡1元3只,现在又100元,要买100只鸡怎么做?

解决方案 »

  1.   

    百元百鸡的问题,最好是用数学来解决。两个for循环就解决了。
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                int daji = 0, xiaoji = 0;
                double money = 0.00;
                for (daji = 0; daji < 100; daji++)
                {
                    xiaoji = 100 - daji;
                    money = daji * 3 + (double)xiaoji / 3.0;
                    if (Math.Abs(money - 100) < 0.00001)
                        Console.WriteLine("Da: {0}, Xiao: {1}.", daji, xiaoji);
                }
            }
        }
    }
      

  3.   

    输出:
    Da: 25, Xiao: 75.