在这里插入代码片
```#include<stdio.h>
#include<windows.h>
#pragma warning(disable:4996)
#define P 1 //一瓶汽水的价格
#define N 2 //换一瓶汽水所需的瓶子数
int sodaConvert(int x){
int ret = x / N;
int empty = x / N + x%N;
if (empty > 1){
return ret + sodaConvert(empty);
}
else
{
return ret;
}
}
int main(){
int p = 0;
int n = 0;
printf("请输入金额:");
scanf("%d", &p);
n = p / P;
int bottle = n + sodaConvert(n);
printf("能买%d瓶\n", bottle);
system("pause");
}
编程喝汽水
最新推荐文章于 2024-10-26 23:34:19 发布