样例:
Input:
5
lebron 100
a 99
god 99
james 100
is 100
output:
lebron 100
james 100
is 100
a 99
god 99
思路:
应该算是打卡题了,看清题目就OK了
参考代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=11111111;
int maxx=-0x3f3f3f3f;
int n;
struct stu
{
int num;char name[111];int score;bool operator<(const stu &b){
if(score==b.score) return num<b.num;else return score>b.score;}
}a[maxn];
int main()
{
cin>>n;for(int i=1;i<=n;i++){
cin>>a[i].name>>a[i].score;a[i].num=i;}sort(a+1,a+n+1);for(int i=1;i<=n;i++){
cout<<a[i].name<<" "<<a[i].score<<endl;}return 0;
}