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");
}
代码:#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");
}
相关文章推荐
- PAT 甲级 1006. Sign In and Sign Out
- 1006. Sign In and Sign Out (25) PAT 甲级
- PAT甲级真题及训练集(8)--1006. Sign In and Sign Out (25)
- PAT 甲级 1006. Sign In and Sign Out (25)
- PAT甲级 1006. Sign In and Sign Out (25)
- 浙江大学PAT_甲级_1006. Sign In and Sign Out (25)
- PAT甲级 1006.Sign In and Sign Out(25) 题目翻译与答案
- 【PAT甲级】【C++】1006. Sign In and Sign Out (25)
- 【PAT甲级】1006 Sign In and Sign Out(25)——JAVA实现
- PAT - 甲级 - 1006. Sign In and Sign Out (25
- [PAT甲级]1006. Sign In and Sign Out (25)(找出机房开门锁门的人)
- [PAT-甲级]1006.Sign In and Sign Out
- PAT 甲级 1006. Sign In and Sign Out
- PAT甲级1006. Sign In and Sign Out
- PAT(甲级)1006. Sign In and Sign Out (25)
- pat甲级1006-Sign In and Sign Out
- PAT(甲级)1006. Sign In and Sign Out (25)
- PAT甲级 1006. Sign In and Sign Out (25)
- PAT甲级1006. Sign In and Sign Out (25)
- PAT TEST甲级1006. Sign In and Sign Out (25)