喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。编程实现。
2017-11-12 13:00
537 查看
int main() { int _bottle = 0;//当空瓶为奇数个时,表示剩下的瓶子 int money = 20; int count = 0;//总共的汽水数 int bottle=0;//空瓶数 if (money > 0) { count = money; bottle = money; } while (bottle != 1) { if (bottle % 2 == 0) { count += bottle / 2; bottle = bottle / 2; } else { count += bottle / 2; _bottle = bottle % 2; bottle = bottle / 2 + _bottle; } } printf("%d\n", count); return 0; }
相关文章推荐
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。编程实现。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。编程实现。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。编程实现。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。编程实现。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。编程实现。
- 编程实现:每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。
- 每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水。(编程实现)。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以买多少汽水
- .喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以喝多少汽水。
- 每瓶汽水1元,两个空瓶可以置换一瓶汽水, 现在有20元,最多能喝多少瓶汽水。(编程实现)。
- 生活中的小代码,每瓶汽水1元,两能喝多少瓶个空瓶可以置换一瓶汽水,现有20元,最多 能喝多少瓶汽水。(编程实现)
- C语言- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水?
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水。
- .每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水
- 【C语言】【面试题】每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水
- C语言:每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水。
- 面试,递归:买汽水,1块钱可以买1瓶汽水,2个空瓶可以换一瓶汽水,3个瓶盖可以换一瓶汽水,问:20块可以买到多少瓶汽水