/3
CS301111 15:30:28 17:00:10
SC3021234 21:45:00 11:25:25
CS301133 08:00:00 21:58:40
这是测试用例,first和last,我基本上是用一种方法写出来的,为什么first.id 就是烫?/
#include<stdio.h>
#include<stdlib.h>
typedef struct time {
int hour;
int min;
int sec;
} time;
typedef struct person {
char id[15];
time intime;
time outtime;
} person;
int compare(time a,time b) {
if (a.hour > b.hour)
return 1;
else if (a.hour < b.hour)
return 0;
else {
if (a.min > b.min)
return 1;
else if (a.min < b.min)
return 0;
else {
if (a.sec >= b.sec)
return 1;
else if (a.sec < b.sec)
return 0;
}
}
}
int main() {
person needcheck, first, last;
*first.id = "no"; *last.id = "no";
int a;
scanf("%d", &a);
for (int i = 0; i < a; i++) {
scanf("%s %d:%d:%d %d:%d:%d", needcheck.id, &needcheck.intime.hour, &needcheck.intime.min, &needcheck.intime.sec, &needcheck.outtime.hour, &needcheck.outtime.min, &needcheck.outtime.sec);
if (last.id == "no") {
last = needcheck;
}
else {
if (!compare(needcheck.outtime, last.outtime) == 1)
last = needcheck;
}
if (first.id == "no") {
first = needcheck;
}
else {
if (compare(needcheck.intime, first.intime) == 1)
first = needcheck;
}
}
printf("%s %s",last.id,first.id);
return 0;
}