注意点:
字符串可以直接比较大小。
代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s1, s2, s3, min, max, ans1, ans2;
int i, n;
cin >> n;
min = "23:59:59";
max = "00:00:00";
for (i = 0; i < n; i++)
{
cin >> s1 >> s2 >> s3;
if (s2 < min)
{
ans1 = s1;
min = s2;
}
if (s3 > max)
{
ans2 = s1;
max = s3;
}
}
cout << ans1 << " " << ans2 << endl;
return 0;
}