Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does C++ solve the problem of soda bottles?

Shulou Source: shulou.com Published: 2022-06-01 19:11:07 10月03日 Update

This article mainly introduces "how C++ solves the problem of soda bottles". In daily operation, I believe many people have doubts about how to solve the problem of soda bottles on C++. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to solve the problem of soda bottles by C++". Next, please follow the editor to study!

Topic description

There is such an intelligence problem: "A store stipulates that three empty soda bottles can be exchanged for one bottle of soda. Xiao Zhang has ten empty soda bottles in her hand. How many bottles of soda can she change at most?" The answer is 5 bottles, the method is as follows: first exchange 9 empty bottles for 3 bottles of soda, drink 3 full bottles, after drinking 4 empty bottles, trade 3 for 1 bottle, drink this full bottle, then there are 2 empty bottles left. Then you ask your boss to lend you a bottle of soda, drink the full bottle, and return it to the boss with three empty bottles. If Xiao Zhang has n empty soda bottles in his hand, how many bottles of soda can be changed at most?

Enter a description:

The input file contains up to 10 sets of test data, each on a line, and contains only one positive integer n (1 n) {

If (nasty 0)

Break

Cout

Tags: Soda bottle problem Clearing input output one line data Xiao Zhang method more boss help test practical next one three two. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Apple Huawei macOS