32分 求助dalao
  • 板块P1104 生日
  • 楼主chenxuwen
  • 当前回复8
  • 已保存回复8
  • 发布时间2022/8/11 14:30
  • 上次更新2023/10/27 15:57:26
查看原帖
32分 求助dalao
547841
chenxuwen楼主2022/8/11 14:30
#include<bits/stdc++.h>
using namespace std;
int n;
struct node{
	string name;
	int y,m,d;
	void in(){
		cin>>name>>y>>m>>d;
	}
}st[105];
bool cmp(node x,node y){
	if(x.y==y.y){
		if(x.m==y.m){
			if(x.d==y.d){
				return 1;
			}else if(x.d<y.d){
				return 1;
			}
		}else if(x.m<y.m){
			return 1;
		}else{
			return 0;
		}
	}else if(x.y<y.y){
		return 1;
	}else{
		return 0;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++){
		st[i].in();
	}
	sort(st,st+n,cmp);
	for(int i=0;i<n;i++){
		cout<<st[i].name<<endl;
	}
	return 0;
}
2022/8/11 14:30
加载中...