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;
}

 

 

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