fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <sstream>
  5.  
  6. int main()
  7. {
  8. std::map<std::string, int> phoneBook;
  9.  
  10. int n;
  11. std::string line;
  12.  
  13. std::getline(std::cin, line);
  14. std::istringstream(line) >> n;
  15.  
  16. for (int i = 0; i < n; ++i)
  17. {
  18. std::getline(std::cin, line);
  19. std::string name;
  20. int phoneNumber;
  21. std::istringstream(line) >> name >> phoneNumber;
  22. phoneBook[name] = phoneNumber;
  23. }
  24.  
  25. while (std::getline(std::cin, line))
  26. {
  27. auto iter = phoneBook.find(line);
  28. if (iter != phoneBook.end())
  29. std::cout << iter->first << "=" << iter->second << std::endl;
  30. else
  31. std::cout << "Not found" << std::endl;
  32. }
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 4508KB
stdin
3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry
stdout
sam=99912222
Not found
harry=12299933