1027. MJ, Nowhere to Hide(寻找同IP名字并排序)
来源:互联网 发布:js控制网页打印区域 编辑:程序博客网 时间:2024/04/30 00:51
/*1027. MJ, Nowhere to Hide 大意:给出一系列名字-IP对,找出IP相同的配对名字,并且先出现的名字 为主名,而且按照主名排序 */#include <iostream>#include <string>#include <stdlib.h>#include <algorithm>using namespace std;#define MAX 10000struct info{ string name; string ip;}data[MAX*2+1];struct Match{ string orig; string maja;};Match match[MAX];bool cmp(Match a, Match b){ return a.orig < b.orig; }int main(){ int n; while(cin >> n && n) { for(int i=1; i<=n; i++) cin >> data[i].name >> data[i].ip; int matchIndex = 0; for(int i=1; i<=n; i++) { for(int k=i+1; k<=n; k++) if(data[k].ip != "" && data[i].ip == data[k].ip) { match[matchIndex].orig = data[i].name; match[matchIndex].maja = data[k].name; matchIndex++; data[i].ip = ""; data[k].ip = ""; } } sort(match, match+matchIndex, cmp); for(int i=0; i<matchIndex; i++) cout << match[i].maja << " is the MaJia of " << match[i].orig << endl; cout << endl; } system("pause"); return 0;}
- 1027. MJ, Nowhere to Hide(寻找同IP名字并排序)
- 1027. MJ, Nowhere to Hide
- 1027. MJ, Nowhere to Hide
- 1027. MJ, Nowhere to Hide
- 1027.MJ, Nowhere to Hide
- Sicily 1027. MJ, Nowhere to Hide
- [sicily online]1027. MJ, Nowhere to Hide
- Sicily 1027. MJ, Nowhere to Hide
- 1027. MJ, Nowhere to Hide简单题
- Sicily 1027. MJ, Nowhere to Hide
- sicily 1027. MJ, Nowhere to Hide
- 1027. MJ, Nowhere to Hide题解
- Sicily 1027. MJ, Nowhere to Hide
- sicily 1027. MJ, Nowhere to Hide
- Sicily 1027. MJ, Nowhere to Hide
- sicily 1027. MJ, Nowhere to Hide
- sicily 1027. MJ, Nowhere to Hide
- Sicily 1027. MJ, Nowhere to Hide
- Zend Studio 配色方案插件
- javascript函数式编程例子收集,自己实现
- object references an unsaved transient instance - save the transient instance be
- Ubuntu下安装google中文输入法
- 利用CHARMM-GUI来建立膜双层结构的具体步骤
- 1027. MJ, Nowhere to Hide(寻找同IP名字并排序)
- 莫到三十空余恨:为什么二十几岁是人生的关键
- 银行系统(好像是这样、、)
- 国内外著名开源b2c电子商务系统比较包括asp.net和php
- Design Pattern: Factory Method 模式
- Eclipse开发--多个相互依赖的工程--------经验(git)
- 自定义字符串处理函数(求长度,拷贝、拼接、比较)--两种方法
- c指针
- 谈谈Unicode,ASCII,UTF,GB2312的一些概念