money=10
water=10//2
pinggai=0
kongping=0
zongshu=0
while water>0:
pinggai=pinggai+water
kongping=kongping+water
zongshu=zongshu+water
print("这次可以喝%d瓶水,总计%d瓶水"%(water,zongshu))
water=0
print("(%d瓶水,%d个盖子,%d个瓶子)"%(water,pinggai,kongping))
if pinggai>=4:
print("%d个盖子换%d瓶水"%(pinggai-pinggai%4,pinggai//4))
colas=water+pinggai//4
pinggai=pinggai%4
if kongping>=2:
print("%d个瓶子换%d瓶水"%(kongping-kongping%2,kongping//2))
watercolas=water+kongping//2
kongping=kongping%2
print("(%d瓶水,%d个盖子,%d个瓶子)"%(colas,pinggai,kongping))
print("总计喝掉%d瓶水,剩下%d个盖子和%d个瓶子"%(zongshu,pinggai,kongping))
![](https://i-blog.csdnimg.cn/blog_migrate/00436d733337a195583154ff376a690a.png)