字符串操作,可以直接用string类,用字符数组也可以,但是需要函数操作比较繁琐。
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<ctime>
#include<string> //C++
using namespace std;
int main()
{
// freopen("input.txt","r",stdin);
int n;
string id,in,out,unlockedid,unlockedtime,lockedid,lockedtime;
unlockedtime="23:59:59";
lockedtime="00:00:00";
cin>>n;
while(n--)
{
cin>>id>>in>>out;
if(in<unlockedtime)
{
unlockedtime=in;
unlockedid=id;
}
if(out>lockedtime)
{
lockedtime=out;
lockedid=id;
}
}
cout<<unlockedid<<" "<<lockedid<<endl;
return 0;
}