1006 Sign In and Sign Out (25 分) 用 string字符串 简化时间比较

 #include<iostream>
 #include<string>
 using namespace std;
 
struct Clock{
	char id[16];
	string come;
	string leave;
}temp,earlyest,latest;

int main() {
   	string early="00:00:00",late="23:59:59";
   	int n;
   	scanf("%d",&n);
   	
   	for (int i=0;i<n;i++){
   		cin>>temp.id>>temp.come>>temp.leave;
   		if(temp.come<late)
   		{	
		    late=temp.come;
   	    	earlyest=temp;
		}
	 	if(temp.leave>early)
   		{	
		    early=temp.leave;
   	    	latest=temp;
		}	
	   }
	 	cout<<earlyest.id<<latest.id;
		
   
     return 0;
}
发布了9 篇原创文章 · 获赞 1 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/cw397265362/article/details/90083040