We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Im new in c++, and met a problem in test case 1, and I don't know where the problem is. Does anyone know the problem? Here's the code:
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>#include<map>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intn;cin>>n;map<string,string>phone;for(inti=0;i<n;i++){stringname_temp;stringphone_temp;cin>>name_temp>>phone_temp;phone.insert(pair<string,string>(name_temp,phone_temp));}for(inti=0;i<n;i++){stringquery_temp;stringout_temp;cin>>query_temp;map<string,string>::iteratorit=phone.find(query_temp);if(it!=phone.end()){out_temp=it->second;cout<<query_temp<<"="<<out_temp<<endl;}else{cout<<"Not found"<<endl;}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
Im new in c++, and met a problem in test case 1, and I don't know where the problem is. Does anyone know the problem? Here's the code: