喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水, 给20元,可以多少汽水。 编程实现。
作者:互联网
#include <stdio.h>
#include <stdlib.h>
int main(){
int n = 20;
int sum = 0;
int ex = 0;
int i;
for (i = n; i > 0; i /= 2){
sum += i;
i += ex;
ex = i % 2;
}
printf("%d\n", sum);
system("pause");
return 0;
}
标签:汽水,20,int,sum,ex,空瓶,include 来源: https://blog.csdn.net/qq_45238229/article/details/100043137