签到与签离
每个人的编号、签到时间、签离时间。输出签到最早的人的编号,和签离最晚的人的编号。
输入: 
3 
CS301111 15:30:28 17:00:10 
SC3021234 08:00:00 11:25:25 
CS301133 21:45:00 21:58:40 
输出: 
SC3021234 CS301133
struct node
{
	char id[15];
	int hh,mm,ss;
}temp,zao,wan; //zao存放最早签到,wan存放最晚签离   
 
bool cmp(node A, node B)
{
	if (A.hh != B.hh) return A.hh > B.hh;
	if (A.mm != B.mm) return A.mm > B.mm;
	return A.ss > B.ss;
}
int main()
{
	int n;
	cin >> n;
	zao.hh = 24, zao.mm = 60, zao.ss = 60;   //初始化
	wan.hh = 0, wan.mm = 0, wan.ss = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> temp.id >> temp.hh >> temp.mm >> temp.ss;  //签到中取最小时间
		if (cmp(temp, zao) == false)
			zao = temp;
		cin >> temp.hh >> temp.mm >> temp.ss;    //签离中取最小时间
		if (cmp(temp, wan) == true)
			wan = temp;
	}
	cout << zao.id << wan.id << endl;
	return 0;
}
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号