题目内容
喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水
#include <stdio.h>
int main()
{
int money,bottle,empty;
printf("你有多少钱:");
scanf ("%d",&money);
//买回来的汽水喝掉
bottle = money;
empty = bottle;
//换回来的汽水
while(empty >= 2)
{
bottle += empty / 2;
empty = empty / 2 + empty % 2;
}
printf("总共可以喝%d瓶\n",bottle);
return 0;
//规律:可以喝的瓶数等于2*钱-1;
}