forked from tamycova/30DaysHR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
day8.cpp
39 lines (30 loc) · 923 Bytes
/
day8.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <sstream>
using namespace std;
int main() {
int n,i; cin >> n;
cin.ignore(); // remove that \n from the buffer
map<string,unsigned int> contacts;
for (i = 0; i < n; i++) {
string name;
getline(cin,name);
string temp; // make temp string
unsigned int number; //allocate for phone number
getline(cin,temp); // load number into temp
stringstream convert(temp); // make sstream
if (!(convert >> number)) number = 0; // get number from stream
contacts[name] = number; // set element in map
}
string q;
while(getline(cin,q)) {
if (contacts.find(q) != contacts.end())
cout << q << "=" << contacts[q] << endl;
else cout << "Not found" << endl;
}
return 0;
}