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 for穷举
    {
        class Program
        {
            static void Main(string[] args)
            {
                int cishu = 0;
                for (int x = 0; x <= 150;x++ )
                {
                    for (int y = 0; y <= 75;y++ )
                    {
                        for (int z = 0; z <= 30;z++ )
                        {
                            if (x * 1 + y * 2 + z * 5 == 150)
                            {
                                cishu++;
                                Console.WriteLine("第"+cishu+"种买法,"+x+"个一分,"+y+"个两分,"+z+"个五分");
                            }
                        }
                    }
                }
                Console.WriteLine("一共有"+cishu+"买法");

            }
        }
    }

  • 相关阅读:
    bzoj1904: Musical Water-fence
    bzoj3822: 文学
    bzoj1513: [POI2006]Tet-Tetris 3D
    bzoj4130: [PA2011]Kangaroos
    bzoj2515 Room
    bzoj2518: [Shoi2010]滚动的正四面体
    bzoj4617: [Wf2016]Spin Doctor
    bzoj3086: Coci2009 dvapravca
    bzoj3745: [Coci2015]Norma
    bzoj1837: [CROATIAN2009]cavli 凸包1
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5160537.html
Copyright © 2011-2022 走看看