80分,求调
  • 板块P1104 生日
  • 楼主lanmengfei
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/6/3 17:32
  • 上次更新2023/10/23 13:58:59
查看原帖
80分,求调
625711
lanmengfei楼主2023/6/3 17:32

贴代码:

#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
	string name;
	int n,y,r;
}a[105];
bool cmp(student a,student b){
	if(a.n>b.n)return 1;
	if(a.n<b.n)return 0;
	if(a.n==b.n){
		if(a.y>b.y)return 1;
		if(a.y<b.y)return 0;
		if(a.y==b.y){
			if(a.r>b.r)return 1;
			if(a.r<b.r)return 0;
			if(a.r==b.r)return 1;
		}
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].name>>a[i].n>>a[i].y>>a[i].r;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++){
		cout<<a[n-i-1].name<<endl;
	}
	return 0;
}
2023/6/3 17:32
加载中...