c语言 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天?

来源:百度知道 编辑:UC知道 时间:2024/09/20 21:32:58

#include<iostream>
using namespace std;
int main()
{
int m;
while(scanf("%d",&m)!=EOF)
{
int count=0;
while(m)
{
m--;
count++;
if(count%3==0)
m=m+1;
}
printf("%d\n",count);
}
return 0;
}
或者
#include<iostream>
using namespace std;
int main()
{
int m;
while(scanf("%d",&m)!=EOF)
{
int t1,t2;
t1=m%3;
t2=m/3;
int count=t2*4+t1;
printf("%d\n",count);
}
return 0;
}

谢了呵!!!!