每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水。
#include<stdio.h>
#include<Windows.h>
#define MONEY 20
int main()
{
int count = MONEY;
int bottle = MONEY;
while (1)
{
if (bottle % 2 == 0)
{
bottle = bottle / 2;
count = count + bottle;
}
else
{
count = count + bottle - 1;
break;
}
}
printf("count=%d\n", count);
system("pause");
return 0;
}
最多能喝多少瓶汽水?
最新推荐文章于 2020-08-26 21:44:26 发布