喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水, 给20元,可以喝多少汽水?
#include<stdio.h>
void num(int x) {
int d = 0, w = 0;
int c = x;
while (1) {
if (x == 1) {
printf("%d", c);
break;
}
else if (x % 2 == 0) {
x = x / 2;
c += x;
}
else {
x = (x - 1) / 2;
c += x;
x = x + 1;
}
}
}
int main() {
int x = 20;
num(x);
return 0;
}