代码如下:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,
//给20元,可以多少汽水
int main(void)
{
int num = 20;
int total = num;
int empty = num;
while (empty > 1)
{
total += empty / 2;
empty = empty / 2 + empty % 2;
}
printf("%d", total);
printf("\n");
system("pause");
return 0;
}