(この問題は業務を統合し、文字列の間のmemsetのstrcpyの割り当てを空にすることができます)のシミュレーション--A1006ログインを取得し、サインアウト

 

 

<ビット/ STDC ++ H>の#include 
の#include <math.h>の
 使用 名前空間STDを、
const  int型 MAX_LEN = 100005 ;
構造体人{
     チャー名[ 15 ]。
    int型HH;
    int型MM;
    int型SS;
    int型HH1;
    int型MM1;
    int型SS1; 
}早期に、最近、
INT メイン(){ 
    early.HH = 24 
    early.MM = 0 ; 
    early.SS = 0 ;
    lately.HH = 0 ; 
    lately.MM = 0 ; 
    lately.SS = 0 ;
    int型のn; 
    cinを >> N;
    以下のためにINT iが= 0、I <N; ++ I){ 
        人の一時。
        scanf関数(" %sの%D:%D:%D%Dた:%d:%のD "、temp.name、&temp.HH、&temp.MM、&temp.SS、&temp.HH1、&temp.MM1、&TEMP。 SS1);
        もし(temp.HH <early.HH ||(temp.HH == early.HH && temp.MM <early.MM)||(temp.HH == early.HH && temp.MM == early.MM && temp.SS < 早いです。= temp.HH。
            early.MM = temp.MM。
            early.SS = temp.SS。
            // early.name = temp.name。
            memsetの(early.name、' \ 0 'はsizeof (early.name)); 
            strcpyの(early.name、temp.name)。
        } 
        であれば(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、' \ 0 'はsizeof (lately.name)); 
            strcpyの(lately.name、temp.name)。
        } 
    } 
    COUT << early.name << "  " << lately.name << ENDL。
    システム(一時停止)。
    リターン 0 ; 
}

おすすめ

転載: www.cnblogs.com/JasonPeng1/p/12116474.html