Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report