#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
struct node//时间
{
int hh;
int mm;
int ss;
};
bool later(node n1,node n2)//如果n1比n2晚,返回真,否则返回假
{
if(n1.hh!=n2.hh)
return n1.hh>n2.hh;
else if(n1.mm!=n2.mm)
return n1.mm>n2.mm;
else
return n1.ss>n1.ss;
}
int main()
{
//freopen("in.txt","r",stdin);
string l,r;
node left,right;
left.hh=99,left.mm=99,left.ss=99;
right.hh=-1,left.mm=-1,left.ss=-1;
int k;
cin>>k;
while(k--)
{
string tid;
node tnode1,tnode2;
cin>>tid;
scanf("%d:%d:%d %d:%d:%d",&tnode1.hh,&tnode1.mm,&tnode1.ss,&tnode2.hh,&tnode2.mm,&tnode2.ss);
if(later(left,tnode1))//node1比left早?
{
l=tid;
left=tnode1;
}
if(later(tnode2,right))//node2比right晚?
{
r=tid;
right=tnode2;
}
}
cout<<l<<' '<<r;
return 0;
}
1006. Sign In and Sign Out (25)
最新推荐文章于 2024-02-22 13:03:30 发布
本文介绍了一个使用C++编写的程序,该程序通过定义结构体来表示时间,并实现了一个比较两个时间先后的功能。程序读取一系列时间记录,找出最早和最晚的时间点。

704

被折叠的 条评论
为什么被折叠?



