UVA_11877.第三次比赛C题:The Coco Cola

 题目:

有一个coco cola小店,你可以用三个空瓶换一瓶coco cola饮料,如果你有n个空瓶,你可以喝到多少瓶饮料?

输入输出要求:

intput:最多有10组案例,每组输入一个整数,0不被处理操作。

Output:每组案例输出你能喝到的饮料数。

sample intput:

3

10

81

0

sanple output:

1

5

40

代码如下:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int s;
    while(scanf("%d",&s) && s)
    {
        int f=0,t=0,m;    //t不能定义在循环体外面,否则会将上组案例结果加进去 
        while(s>2)
        {
            f+=s/3;
            m=f-t;
            s=m+s%3;
            t=f;
        }
        if(s==2)
            f++;
        printf("%d
",f);
    }
    return 0;
}

变量定义位置一定多加要注意!!!!

写题很渣,忒特么没有自尊了,但是女汉子还是要坚持下去。天下之患莫过于治平无事,而其实有不测之忧。既然来了就要征服!

原文地址:https://www.cnblogs.com/x512149882/p/4654735.html