#include <stdio.h> #include<iostream> using namespace std; struct ID { char id_num[16]; int begin; int end; }; int main() { int m,H,M,S; struct ID unlock_id,lock_id,tmp_id; unlock_id.begin=99999; lock_id.end=-1; scanf("%d",&m); for(int i=0;i<m;i++) { scanf("%s",tmp_id.id_num); scanf("%d:%d:%d",&H,&M,&S); S=H*3600+M*60; tmp_id.begin=S; scanf("%d:%d:%d",&H,&M,&S); S=H*3600+M*60; tmp_id.end=S; if(tmp_id.begin<unlock_id.begin) unlock_id=tmp_id; if(tmp_id.end>lock_id.end) lock_id=tmp_id; } cout<<unlock_id.id_num<<" "<<lock_id.id_num<<endl; return 0; }
简单的比大小问题,将时间都换算成秒,进行比较。
来源:https://www.cnblogs.com/QRain/p/12284266.html