1006 Sign In and Sign Out (25 point(s))

1006 Sign In and Sign Out (25 point(s))

String sorting, from small to large, from large to small twice, output.

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;
const int inf_int = 1e9;

int M;
struct node{
    
    
    string a,b,c;
}t[maxn];
bool cmp1(node &N1,node &N2){
    
    
    return N1.b < N2.b;
}
bool cmp2(node &N1,node &N2){
    
    
    return N1.c > N2.c;
}
int main(){
    
    
    while(cin>>M){
    
    
        for(int i = 1;i<=M;i++){
    
    
            cin>>t[i].a>>t[i].b>>t[i].c;
        }
        sort(t+1,t+M+1,cmp1);
        cout<<t[1].a<<' ';
        sort(t+1,t+M+1,cmp2);
        cout<<t[1].a<<'\n';
    }





    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326215902&siteId=291194637