您当前的位置: 首页 >  c#

刘一哥GIS

暂无认证

  • 3浏览

    0关注

    934博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

刘一哥GIS 发布时间:2015-06-29 14:11:39 ,浏览量:3

问题:公鸡一只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}"+'\t'+"母鸡:{2}"+'\t'+"小鸡:{3}",++i,x,y,z);
                }
            Console.ReadLine();
        }
    }
}

关注
打赏
1665586602
查看更多评论
立即登录/注册

微信扫码登录

0.0883s