AcWing 3406. 日志排序
原题链接
简单
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<algorithm>
using namespace std;
const int N=10010;
struct log{
string info;
string name;
string begin_day;
string begin_time;
double spend_time;
bool operator < (const log &t)const{
if(spend_time!=t.spend_time){
return spend_time<t.spend_time;
}else{
return begin_day+begin_time<t.begin_day+t.begin_time;
}
}
}log[N];
int main(){
string record;
string line;
int i=0;
while(getline(cin,line) && !line.empty()){
stringstream ssin(line);
log[i].info=line;
ssin>>log[i].name>>log[i].begin_day>>log[i].begin_time>>log[i].spend_time;
i++;
}
sort(log,log+i);
for(int j=0;j<i;j++){
cout<<log[j].info<<endl;
}
return 0;
}