#include <stdio.h>
/*
啤酒两块钱一瓶
4个瓶盖换一瓶
2个瓶子换一瓶
10块可以喝几瓶
*/
int sum = 0;
int getPi(int qian,int ping,int gai)
{
int pi = qian/2+ping/2+gai/4;
sum+=pi;
if(pi<=0)
{
printf("\n总数=>啤酒:%d \n剩余=>瓶子:%d, 瓶盖:%d\n", sum, ping, gai);
return sum;
}
else
{
printf("啤酒:%d => 瓶子:%d, 瓶盖:%d\n", pi, ping%2+pi, gai%4+pi);
return getPi(qian%2,ping%2+pi,gai%4+pi);
}
}
int main()
{
getPi(10,0,0);
return 0;
}
网友评论