#include <iostream>
#include <cstring>
using namespace std ;
/**此结构体包括证件号和时间
* 早晚签到都是证件号和时间
*/
struct node{
string s, t; //证件号和时间
}ft, lt;
int main(){
int N, M;
string ps,pft, plt; //证件号,早起时间,晚上时间
cin>>N;
while (N--){
cin>>M;
M--;
cin>>ps>>ft.t>>lt.t;
ft.s=lt.s = ps; //
while (M--){
cin>>ps>>pft>>plt; //输入第二个人的证件号和时间
if (pft < ft.t){ //如果比第一个人来的早
ft.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
ft.t = pft;
}
if (plt > lt.t) { //如果比第一个人走的晚
lt.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
lt.t = plt;
}
}
cout<<ft.s<<" "<<lt.s<<endl;
}
#include <cstring>
using namespace std ;
/**此结构体包括证件号和时间
* 早晚签到都是证件号和时间
*/
struct node{
string s, t; //证件号和时间
}ft, lt;
int main(){
int N, M;
string ps,pft, plt; //证件号,早起时间,晚上时间
cin>>N;
while (N--){
cin>>M;
M--;
cin>>ps>>ft.t>>lt.t;
ft.s=lt.s = ps; //
while (M--){
cin>>ps>>pft>>plt; //输入第二个人的证件号和时间
if (pft < ft.t){ //如果比第一个人来的早
ft.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
ft.t = pft;
}
if (plt > lt.t) { //如果比第一个人走的晚
lt.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
lt.t = plt;
}
}
cout<<ft.s<<" "<<lt.s<<endl;
}
return 0;
}
本程序通过读取人员的签到记录,找出每天最早到达和最晚离开的员工。使用C++实现,程序首先读取总天数,然后逐天读取参与签到的人数及其证件号和具体时间,通过比较不断更新最早与最晚记录。
373

被折叠的 条评论
为什么被折叠?



