思路:
很简单的排序题
C o d e Code Code:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
struct node
{
string name, c;
}a[1010];
bool cmp(node a, node b)
{
if (a.c.size() != b.c.size())return a.c.size() > b.c.size();//模拟
if (a.c != b.c)return a.c > b.c;
return a.name < b.name;
}
int main()
{
freopen ("water.in","r",stdin);
freopen ("water.out","w",stdout);
scanf("%d", &n);
for (int i = 1; i <= n; ++i) cin>>a[i].name>>a[i].c;
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; ++i) cout <<a[i].name <<endl;
return 0;
}