//sicily 1027 MJ,nowhere to hide
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;
typedef struct In
{
string id;
string ip;
}In;
typedef struct Result
{
string id;
string majia;
}Result;
bool Compare(const Result &str1,const Result &str2)//从小到大排序
{
if(strcmp(str1.id.c_str(),str2.id.c_str()) > 0)
return false;
return true;
}
int main()
{
int num;
In data[1000] = {""};
Result result[1000] = {""};
vector<Result> res;
res.clear();
while(scanf("%d",&num) && num != 0)
{
for(int i = 0;i < num;i++)//输入数据
{
cin >> data[i].id >> data[i].ip;
}
//找出ip相同的id,并将其放入结构体中
int k = 0;
for(int i = 0;i < num - 1;i++)
for(int j = i + 1;j < num;j++)
{
if(data[i].ip == data[j].ip)//j中ip对应的id是i中ip对应id的马甲
{
result[k].id = data[i].id;
result[k].majia = data[j].id;
res.push_back(result[k++]);
}
}
sort(res.begin(),res.end(),Compare);
for(int m = 0;m < res.size();m++)
cout << res[m].majia << " is the MaJia of " << res[m].id << endl;
res.clear();
printf("\n");
}
return 0;
}
sicily 1027 MJ,nowhere to hide
最新推荐文章于 2019-03-28 17:46:26 发布