Skip to content

Instantly share code, notes, and snippets.

@roxsula
Created February 14, 2019 20:41
Show Gist options
  • Save roxsula/93454d8d34145aa6b7b180caf054d282 to your computer and use it in GitHub Desktop.
Save roxsula/93454d8d34145aa6b7b180caf054d282 to your computer and use it in GitHub Desktop.
Dictionary in C++
#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