逻辑题,看看你的逻辑思想是否成熟?请用JAVA写出
total = 0;money = 10;bottle =0;cap = 0;while(money \u0026gt;=2 or bottle \u0026gt;=2 or cap \u0026gt;= 4){buy = money / 2 + bottle / 2 + cap / 4;total += buy;money = money mod 2;bottle = bottle mod 2 + buy;cap = cap mod 4 + buy;}print total;如果可以借空瓶子和瓶盖的话:total = 0;money = 10;bottle =0;cap = 0;while(money \u0026gt;=2 or bottle \u0026gt;= 1 or cap \u0026gt;= 3){borrowBottle = false;borrowCap =false;if money \u0026lt;=1 and bottle = 1 and cap \u0026lt;= 3 then{bottle += 1;borrowBottle = true;}else if money \u0026lt;= 1 and bottle = 0 and cap = 3 then{cap +=1;borrowCap = true;}buy = money / 2 + bottle / 2 + cap / 4;total += buy;money = money mod 2;bottle = bottle mod 2 + buy;cap = cap mod 4 + buy;if borrowBottle then{bottle -= 1;}if borrowCap then{cap -=1;}}print total;爪机无力排版请别拍砖。
■网友
逻辑题为何非要用JAVA写呢?
推荐阅读
- 如果你的多肉出现这个长势,要注意这个细节,多肉才会越来越美!
- 装置■一天效益百万的国产装置见过没?一起去大修现场看看吧
- 奥迪|20万起能买豪华SUV? 看看这台21款的奥迪Q2L!
- 肝脏|比生气还伤肝的5个行为,在“悄悄”损伤你的肝,尽量改掉
- 侧重业务逻辑的产品需求规格说明书,需要有哪些要点
- 心流西春|为何你的后半箱油总是不耐用?油是正经油,问题可能出在这里
- 在路上|在路上开廉价车和豪车的区别,看看网友的真实体会
- 淘宝店卖杯子咋推广咋做9.9包邮的爆款有作用吗
- 胖哥试车|电动车的颜值巅峰 最懂你的AION Y来了
- 天天汽车|超高性价比实力宠粉,2021款奕歌能否点燃你的心?