1006 Sign In and Sign Out (25 分)
题目链接
算法分析
开两个结构体数组,用sort排序即可
代码实现
#include<bits/stdc++.h>
using namespace std;
#define N 10005
typedef struct{
string name;
string in;
string out;
}ind;
ind tma[N], tmb[N];
bool cmp1(const ind a, const ind b){
return a.in < b.in;
}
bool cmp2(const ind a, const ind b){
return a.out > b.out;
}
int main(){
int m;
string s;
scanf("%d", &m);
for(int i = 1; i <= m; ++ i){
cin>> tma[i].name >> tma[i].in>> tmb[i].out;
tmb[i].name = tma[i].name;
}
sort(tma + 1, tma + m + 1, cmp1);
sort(tmb + 1, tmb + m + 1, cmp2);
cout<< tma[1].name<< ' '<< tmb[1].name;
return 0;
}