0

Why does it output 4198693.

Safety Deposit Boxes You are robbing a bank, but you’re not taking everything. You are looking for a specific item in the safety deposit boxes and you are going to drill into each one in order to find your item. Once you find your item you can make your escape, but how long will it take you to get to that item? Task Determine the amount of time it will take you to find the item you are looking for if it takes you 5 minutes to drill into each box. Input Format A string that represent the items in each box that will be drilled in order (items are separated by a comma), and secondly, a string of which item you are looking for. Output Format An integer of the amount of time it will take for you to find your item. Sample Input 'gold,diamonds,documents,Declaration of Independence,keys' 'Declaration of Independence' Sample Output 20 https://code.sololearn.com/cSC9B0zp1VN7/?ref=app

31st Aug 2022, 11:32 PM
Costy Game
Costy Game - avatar
1 Answer
+ 3
Local variables are not default-initialized to any value, meaning until you write to them they will contain garbage values (whatever was stored in that memory location before). Therefore, you should explicitly set `sum` to zero. The use of std::cin is likely going to cause problems with this challenge as the strings can contain whitespace, but std::cin stops reading input when encountering spaces. You might want to have a look at std::getline instead: https://en.cppreference.com/w/cpp/string/basic_string/getline
31st Aug 2022, 11:50 PM
Shadow
Shadow - avatar