开门与关门人HDOJ

题目链接

http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=3&problemid=7



#include <iostream>
using namespace std;
struct Info{
	char name[17];
	int totals;//开始时间,时分秒
	int totale;
};
struct Info staff[100];
int main()
{
	int days;
	int npeop;
	cin>>days;
	while(days--)
	{
		cin>>npeop;
		for (int i = 0; i < npeop; ++i)
		{
			char strs[10],stre[10];
			int   hh,mm,ss;
			cin>>staff[i].name>>strs>>stre;
			sscanf(strs,"%d:%d:%d",&hh,&mm,&ss);
			staff[i].totals = hh*3600+mm*60+ss;
			sscanf(stre,"%d:%d:%d",&hh,&mm,&ss);
			staff[i].totale =  hh*3600+mm*60+ss;
		}
		int stand = staff[0].totals;
		int ans=0;
		for(int i=1;i<npeop;++i)
		{
			if (staff[i].totals <staff[ans].totals)
				ans = i;
		}
		cout<<staff[ans].name<<" ";
		 stand = staff[0].totale;
		 ans=0;
		for(int i=1;i<npeop;++i)
		{
			if (staff[i].totale >staff[ans].totale)
				ans = i;
		}
		cout<<staff[ans].name<<endl;
	}
	return 0;
}



发布了37 篇原创文章 · 获赞 14 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/xiaod_szu/article/details/8448359