Birthday solution to a problem

+ Cmd with structure

Logic chaos on the line

Key to see comments

#include <bits / STDC ++ H.> // universal header 
the using  namespace STD;
 const  int N = 110 ;
 struct Classmate {
     String name; // name 
    int Y; // year 
    int m; // month 
    int D; // date 
    int NUM; // enter the first few rows 
} a [N];
 BOOL cmd (Classmate x, y Classmate) // input order of forward ratio y x 
{
     returnxy <yy || (xy == yy && xm <ym) || (xy == yy && xm == ym && xd <yd) || (xy == yy && xm == ym && xd == yd && x.num> y.num);
         / * 
            1. x is smaller than y of the year; 
            the same year 2. x and y, x is smaller than y of the month; 
            3. year x, y in the same month , the date of x is less than y; 
            4. x year, month, and y is the same date, by the output order of the ratio y of x. 
        * / 
} 
Int main () 
{ 
    int n-; 
    CIN >> n-;
     for ( int I = . 1 ; I <= n-; I ++ ) { 
        CIN >> A [I] .name >> A [I] .y >> A [I] .m >> A [I] 2.d; 
        A [I] .num = I;
+1,a+n+1,cmd);//c++自带STL,排序
    for(int i=1;i<=n;i++)
        cout<<a[i].name<<"\n";
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/Ryan-juruo/p/11530569.html