您的位置:首页 > 其它

PAT(甲级)1006. Sign In and Sign Out

2017-01-21 16:37 363 查看
题目:https://www.patest.cn/contests/pat-a-practise/1006

代码:#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
struct per{
char id[16];
int h,m,s;
}temp,late,early;
bool later(per a,per b)
{
if(a.h!=b.h) return a.h>b.h;
if(a.m!=b.m) return a.m>b.m;
return a.s>b.s;

}
int main()
{
int m;
scanf("%d",&m);
early.h=24,early.m=60,early.s=60;
late.h=0,late.m=0,late.s=0;
while(m--)
{
scanf("%s %d:%d:%d",&temp.id,&temp.h,&temp.m,&temp.s);
if(later(temp,early)==false) early =temp;
scanf("%d:%d:%d",&temp.h,&temp.m,&temp.s);
if(later(temp,late)==true) late=temp;
}
printf("%s %s",early.id,late.id);
system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: