開門與關門人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;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章