#include<cstdio>
#include<cstring>
#include<memory.h>
#include<algorithm>
using namespace std;
struct E {
char all[100];
char startTime[30];
float comsumption;
bool operator<(const E &b) const{
if(comsumption!=b.comsumption)
return comsumption<b.comsumption;
else
return strcmp(startTime,b.startTime)<0;
}
}logs[10001];
int main(){
int k=0;
char name[20],date[20],time[20];
while(gets(logs[k].all)&&strcmp(logs[k].all,"")!=0){
memset(logs[k].startTime,0,sizeof(logs[k].startTime));
sscanf(logs[k].all,"%s %s %s %f(s)",name,date,time,&logs[k].comsumption);
strcat(logs[k].startTime,date);
strcat(logs[k].startTime,time);
k++;
}
sort(logs,logs+k);
for(int i=0;i<k;i++){
puts(logs[i].all);
}
return 0;
}
日志排序【北京大学】
最新推荐文章于 2022-08-29 08:57:24 发布