Created
February 14, 2019 20:41
-
-
Save roxsula/93454d8d34145aa6b7b180caf054d282 to your computer and use it in GitHub Desktop.
Dictionary in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <string.h> | |
#include <map> | |
using namespace std; | |
int main() { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
string k; | |
string q; | |
long v; | |
int n; | |
map <string, long> phone_list; | |
cin >> n; | |
cin.ignore(); | |
for(int i=0; i<n; i++) | |
{ | |
cin >> k; | |
cin >> v; | |
phone_list[k]=v; | |
} | |
while(cin >> q) | |
{ | |
if (phone_list.count(q)>0) cout << q << "=" << phone_list[q] << endl; | |
else cout << "Not found" << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment