首页 > 其他 > 详细

Sicily 1027. MJ, Nowhere to Hide

时间:2016-05-11 23:13:44      阅读:181      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!