The Washer That Appeared
What does this print?
std::map<std::string, int> inventory{{"bolt", 12}, {"nut", 40}};
int total = 0;
for (const std::string &part : {"bolt", "washer", "nut"}) {
if (inventory[part] > 0) total += inventory[part];
}
std::cout << total << " " << inventory.size() << "\n";
Sign in to answer questions and track your progress
Sign In