码迷,mamicode.com
首页 > 其他好文 > 详细

for 循环练习题

时间:2016-04-18 11:35:43      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

          int m = 0;
           for (int x = 1; x * 3 <= 200; x++)
           {
               for (int y = 1; y * 2 <= 200; y++)
               {
                   for (int z = 1; z * 15 <= 200; z++)
                   {
                       if (3 * x + 2 * y + 15 * z == 200)
                       {
                           Console.WriteLine(x + "个牙刷" + y + "个香皂" + z + "副羽毛球拍");
                           m++;
                       }
                   }

               }

           }
           Console.WriteLine("一共有多少种方法" + m);

for 循环练习题

标签:

原文地址:http://www.cnblogs.com/qz1234/p/5403672.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!