zoukankan      html  css  js  c++  java
  • 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 + "种结果");
            }
        }
    }

  • 相关阅读:
    b_lc_数组的最大公因数排序(并查集+质因数分解优化)
    Coggle 30 Days of ML:结构化赛题:天池二手车交易价格预测(二)
    Coggle 30 Days of ML:结构化赛题:天池二手车交易价格预测(一)
    漫谈
    漫谈
    漫谈
    漫谈
    漫谈
    漫谈
    漫谈
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5194621.html
Copyright © 2011-2022 走看看