码迷,mamicode.com
首页 > 其他好文 > 详细

Sicily 1027. MJ, Nowhere to Hide

时间:2016-05-11 23:15:04      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

//就是一个简单的字符串配对~~用map来解决很easy

#include <iostream> #include <map> #include <string> using namespace std; int main() { int n; while (cin>>n && n!=0) { string ip , name; string tmp; map<string,string> m; map<string,string>::iterator iter; map<string,string> ans; while(n--){ cin>> name >> ip; if ((iter = m.find(ip) )!= m.end()) { ans.insert(make_pair(iter->second, name+"is the MaJia of "+ iter->second)); m.erase(iter); }else m.insert(make_pair(ip, name)); } for(iter = ans.begin() ; iter != ans.end(); iter++) cout << iter->second << endl; cout << endl; } return 0; }

 

Sicily 1027. MJ, Nowhere to Hide

标签:

原文地址:http://www.cnblogs.com/zhousysu/p/5483671.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!