其他分享
首页 > 其他分享> > 1006 Sign In and Sign Out

1006 Sign In and Sign Out

作者:互联网

#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;
struct people {
    char name[16];
    int in;
    int out;
}t;
int main() {
    vector<people>s;
    int a, b, c, d, e, f, i, j,m;
    vector<int>time;
    char n[16];
    scanf("%d", &m);
    for (i = 1; i <= m; i++) {
        scanf("%s", &n);
        scanf("%d:%d:%d", &a, &b, &c);
        scanf("%d:%d:%d", &d, &e, &f);
        strcpy(t.name, n);
        t.in = a * 3600 + b * 60 + c;
        t.out = d * 3600 + e * 60 + f;
        s.push_back(t);
        time.push_back(a * 3600 + b * 60 + c);
        time.push_back(d * 3600 + e * 60 + f);
    }
    sort(time.begin(),time.end());
    for (i = 0; i <= m; i++)
        if (s[i].in == time.front()) {
            printf("%s ", s[i].name);
            break;
        }
    for (i = 0; i <= m; i++)
        if (s[i].out == time.back()) {
            printf("%s", s[i].name);
            break;
        }
    return 0;
}

标签:std,16,int,Sign,char,1006,include,Out
来源: https://blog.csdn.net/yyd_s/article/details/122614406