84分求助
查看原帖
84分求助
661595
a2lyaXNhbWUgbWFyaXNh楼主2022/7/3 17:32

RT,改了很多遍了

#include<bits/stdc++.h>
using namespace std;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-'){
            f=-1;
    	}
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

inline void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9){
    	write(x/10);
	}
    putchar(x%10 +'0');
}

struct friends{
    string name;
    int  year,month,day;
    long long int birsday;
};
inline bool mycmp(friends a,friends b){
    return a.birsday<=b.birsday;
}
int main(){
    int s;
    cin>>s;
    friends student[s];
    for(int i=0;i<s;i++){
        cin>>student[i].name;
        student[i].year=read();
        student[i].month=read();
        student[i].day=read();
        student[i].birsday=student[i].year*10000+student[i].month*100+student[i].day;
    }
    sort(student,student+s,mycmp);
    for(int j=0;j<s;j++){
        cout<<student[j].name<<endl;
    }
    return 0;
}
2022/7/3 17:32
加载中...