commit b14d4d2f2c1ed06c6ff7310ab1e5703b6a4c17b7 parent cb348f72850a150ecadab892f89f9697b46e8191 Author: AndrewLockVI <andrewlaack1@gmail.com> Date: Mon, 10 Apr 2023 14:07:36 -0500 Completed water bottle logic problem Diffstat:
| A | water-bottles/a.out | | | 0 | |
| A | water-bottles/water-bottles.cpp | | | 35 | +++++++++++++++++++++++++++++++++++ |
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/water-bottles/a.out b/water-bottles/a.out Binary files differ. diff --git a/water-bottles/water-bottles.cpp b/water-bottles/water-bottles.cpp @@ -0,0 +1,35 @@ +#include <iostream> +using namespace std; + + + +//Leet Ratings +// Speed Memory +//Total 0ms 5.9MB +//Beats 100% 61.85% + + + +int numWaterBottles(int numBottles, int numExchange) { + + //numBottles is used to track the number of empty bottles + //given that all bottles are drank right at the beginning. + int num_drank = numBottles; + while(numBottles >= numExchange){ + num_drank += 1; + numBottles += 1; + numBottles = numBottles - numExchange; + } + return num_drank; +} + + +int main(){ + cout << "Number of Bottles To Start: "; + int bottles_start = 0; + int bottles_exchange = 0; + cin >> bottles_start; + cout << "Number of Bottles To Exchange: "; + cin >> bottles_exchange; + cout << numWaterBottles(bottles_start, bottles_exchange) << endl; +}