Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- int main()
- {
- std::map<std::string, std::string>
- phonebook;
- phonebook.emplace(
- std::pair<std::string, std::string>
- {"Baabel", "08-5522134"}
- );
- phonebook["Santa Maria"] = "08-344887";
- phonebook["Turtles"] = "08-5555595";
- for (const auto& entry : phonebook)
- {
- std::cout << entry.first << " - "
- << entry.second << "\n";
- }
- std::string input;
- std::cout << "Enter name\n";
- while(std::getline(std::cin, input))
- {
- if (input.empty())
- break;
- if (phonebook.count(input) != 0)
- std::cout << phonebook[input] << "\n";
- else
- std::cout << "not in phonebook\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement