当前位置:网站首页>1006 sign in and sign out (25 points)

1006 sign in and sign out (25 points)

2022-06-21 07:53:00 Crer_ lu

1006 Sign In and Sign Out (25 branch )

Topic link

Algorithm analysis

Open two structure arrays , use sort Sorting can be

Code implementation

#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;
}
原网站

版权声明
本文为[Crer_ lu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210747123879.html