Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- bool isFound(map<string, string>& m, string& s) {
- for (auto it = m.begin(); it != m.end(); it++) {
- if (it->first == s) {
- return true;
- }
- }
- return false;
- }
- int main()
- {
- string line, name, id;
- map<string, string> companies = {};
- while (true) {
- getline(cin, line);
- if (line == "end") {
- break;
- }
- name = line.substr(0, line.find(' '));
- id = line.substr(line.find(' ') + 1);
- companies.insert({ id, name });
- }
- cin >> id;
- printf(!isFound(companies, id) ? "[not found]\n" : "%s %s\n", companies[id].c_str(), id.c_str());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement