pat 1006
来源:互联网 发布:微信群淘宝客机器人 编辑:程序博客网 时间:2024/04/30 15:55
题意:有许多人来电脑教室,问最早来的,和最晚走的
思路:循环一遍时间存成秒,比大小,输出
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1000000005;
int n;
char ans1[20],ans2[20];
char name[20],t[20];
int ch(char a){
return a-'0';
}
int main()
{
int Max=0,Min=INF,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",name);
scanf("%s",t);
int temp=0;
temp=(ch(t[0])*10+ch(t[1]))*3600;
temp+=(ch(t[3])*10+ch(t[4]))*60;
temp+=ch(t[6])*10+ch(t[7]);
if(temp<Min){
Min=temp;
strcpy(ans1,name);
}
scanf("%s",t);
temp=(ch(t[0])*10+ch(t[1]))*3600;
temp+=(ch(t[3])*10+ch(t[4]))*60;
temp+=ch(t[6])*10+ch(t[7]);
if(temp>Max){
Max=temp;
strcpy(ans2,name);
}
}
printf("%s %s\n",ans1,ans2);
return 0;
}
0 0
- pat 1006
- PAT 1006
- PAT 1006
- pat 1006
- PAT 1006
- PAT 1006
- PAT 1006
- PAT 1006
- PAT 1006
- PAT-1006
- PAT Basic 1006
- PAT 1006的坑
- PAT (Basic) 1006~1010
- PAT BASIC 1006
- PAT(A) 1006
- PAT(甲级)1006
- PAT Basic 1006
- PAT甲级1006
- struts2的优点
- poj1961--Period(KMP求最小循环节)
- 一个人的旅行 hdu 2066
- 使用ASP.NET MVC 4 Bootstrap Layout Template(VS2012)
- bluetooth LE HOGP profile的代码大致实现流程(HOGP+GATT)
- pat 1006
- Swift基础--ijkplayer编译
- struts2如何完成文件的上传
- Xcode及Mac快捷键大全
- ContentProvider(内容提供者)用法详解
- 【Spring.Framework】依赖管理, Logging
- hdu-oj 2516 取石子游戏 ( 博弈)
- git 删除已经 add 的文件
- JAVA设计模式之 抽象工厂模式【Abstract Factory Pattern】