热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_46318413
@Dai
3 年前
trueweixin_46318413

灵隐寺打卡

CSDN App 扫码分享
分享
评论
2
打赏
  • 复制链接
  • 举报
下一条:
写了个程序解决这个问题,上面用多少车的做出来了,后面价格排比怎么也想不明白怎么做,求教大佬代码:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 练习_垃圾清运 { class Program { static void Main(string[] args) { Console.WriteLine("请输入垃圾站需要清运的垃圾总重量:");//提示 Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\n\n垃圾站需要清运" + all + "吨的垃圾,如果用两种车辆清运:\n\n一种载重3吨的大车,一种载重2吨的小车,请列举全部清运完所有的可能"); for (int i = 0; i <= all / 3; i++)//第一个循环大车:初始车辆等于0,车辆运送总次数小于总吨数除以大车载重量,每个循环+1 { for (int j = 0; j <= (all - 3 * i) / 2; j++)//第二个循环小车:初始车辆=0,车辆运送总次数等于总重量减去大车运送的总重量除以小车的载重量; { if ((j * 2 + i * 3) == all)//如果两个车的总载重量等于输入的重量 Console.WriteLine("\n\n3吨的大车运" + i + "车,2吨的小车运" + j + "车");//输出列举可能出现的运送次数 } Console.WriteLine(i); } Console.ReadKey(); } } }
立即登录