Edición de fecha 2017G

http://oj.ecustacm.cn/problem.php?id=1328

#include <bits / stdc ++. h>
 usando el  espacio de nombres std;
struct node {
     int y, m, d; 
} s [ 10 ];
int cnt;
int a, b, c;
verificación nula ( int aa, int mm, int dd) {
     int mes [ 13 ] = { 0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 ,31 };
    si (aa> = 60 ) 
        aa + = 1900 ;
    de lo contrario yy + = 2000 ; 

    if (aa% 400 == 0 || (aa% 4 == 0 && aa% 100 ! = 0 )) 
        mes [ 2 ] ++ ;
    if (mm> 0 && mm < 13 ) {
         if (dd> 0 && dd <= mes [mm]) { 
            s [cnt] .y = aa; 
            s [cnt] .m= mm; 
            s [cnt ++]. d = dd; 
        } 
    } 
} 

bool cmp (nodo aa, nodo bb) {
     if (aa.y! = bb.y)
         devuelve aa.y < bb.y;
    de lo contrario,  si (aa.m! = bb.m)
         devuelve aa.m < bb.m;
    devuelve aa.d < bb.d; 
} 
int main () { 
    scanf ( " % d /% d /% d " , & a, & b, & c); 
    cheque (c, a, b); 
    cheque (c, b, a); 
    cheque (a, b, c); 

    ordenar (s, s +cnt, cmp);
    para ( int i = 0 ; i <cnt; i ++ ) {
         if (i && s [i] .y == s [i - 1 ] .y && s [i] .m == s [i - 1 ]. m && s [i] .d == s [i - 1 ] .d)
             continuar ; 
        printf ( " % d-% 02d-% 02d \ n " , s [i] .y, s [i] .m, s [i] .d); 
    } 
    devuelve  0 ; 
}

 

Supongo que te gusta

Origin www.cnblogs.com/xcfxcf/p/12710637.html
Recomendado
Clasificación