• 入门模拟——A1006 Sign in and Sign out (这个题可以巩固字符串之间赋值strcpy和清空memset的操作)


    #include <bits/stdc++.h>
    #include<math.h>
    using namespace std;
    const int MAX_LEN = 100005;
    struct Person{
        char name[15];
        int HH;
        int MM;
        int SS;
        int HH1;
        int MM1;
        int SS1;
    }early,lately;
    int main(){
        early.HH = 24;
        early.MM = 0;
        early.SS = 0;
        lately.HH = 0;
        lately.MM = 0;
        lately.SS = 0;
        int n;
        cin>>n;
        for(int i=0;i<n;++i){
            Person temp;
            scanf("%s %d:%d:%d %d:%d:%d",temp.name,&temp.HH,&temp.MM,&temp.SS,&temp.HH1,&temp.MM1,&temp.SS1);
            if(temp.HH<early.HH || (temp.HH == early.HH && temp.MM<early.MM)||(temp.HH==early.HH && temp.MM == early.MM && temp.SS<early.SS)){
                early.HH = temp.HH;
                early.MM = temp.MM;
                early.SS = temp.SS;
                //early.name = temp.name;
                memset(early.name,'',sizeof(early.name));
                strcpy(early.name, temp.name);
            }
            if(temp.HH1>lately.HH || (temp.HH1 == lately.HH && temp.MM1>lately.MM)||(temp.HH1==lately.HH && temp.MM1 == lately.MM && temp.SS1>lately.SS)){
                lately.HH = temp.HH1;
                lately.MM = temp.MM1;
                lately.SS = temp.SS1;
                memset(lately.name,'',sizeof(lately.name));
                strcpy(lately.name,temp.name);
            }
        }
        cout<<early.name<<" "<<lately.name<<endl;
        system("pause");
        return 0;
    } 
  • 相关阅读:
    1009 Product of Polynomials (25分)
    VS code 调试C++
    1065 A+B and C (64bit) (20分)
    UML与数据库应用系统
    语句(switch,异常,NDEBUG,assert)
    1046 Shortest Distance (20分)
    1042 Shuffling Machine (20分)
    模块和包
    闭包&装饰器
    迭代器、生成器
  • 原文地址:https://www.cnblogs.com/JasonPeng1/p/12116474.html
Copyright © 2020-2023  润新知