uva_11877. Third competition C: the Coco Cola

Source: Internet
Author: User

Title:

There is a Coco Cola store, you can use three empty bottles for a bottle of Coco Cola Drink, if you have n empty bottles, how many bottles of drink can you drink?

Input/Output requirements:

Intput: There are up to 10 groups of cases, each of which enters an integer and 0 is not manipulated.

Output: Each set of cases outputs the number of drinks you can drink.

Sample intput:

3

10

81

0

Sanple output:

1

5

40

The code is as follows:

#include <iostream>#include<cstdio>using namespacestd;intMain () {ints;  while(SCANF ("%d", &s) &&s) {intf=0, t=0, M; T cannot be defined outside the loop body, otherwise the results of the previous group of cases will be added while(s>2) {f+=s/3; M=f-T; S=m+s%3; T=F; }        if(s==2) F++; printf ("%d\n", F); }    return 0;}

Variable definition location must be more attention!!!!

Write the question is very slag, Theseus do not have self-esteem, but female man still want to persist. There is nothing in the world to cure flat, but there are accidents in fact. If you come, you must conquer!

uva_11877. Third competition C: the Coco Cola

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.