2017G日期问题
http://oj.ecustacm.cn/problem.php?id=1328
#include <bits/stdc++.h> using namespace std; struct node{ int y,m,d; }s[10]; int cnt; int a,b,c; void check(int yy,int mm,int dd){ int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; if(yy >= 60) yy += 1900; else yy += 2000; if(yy % 400 == 0 || (yy % 4 == 0 && yy % 100 != 0)) month[2]++; if(mm > 0 && mm < 13){ if(dd > 0 && dd <= month[mm]){ s[cnt].y = yy; s[cnt].m = mm; s[cnt++].d = dd; } } } bool cmp(node aa,node bb){ if(aa.y != bb.y) return aa.y < bb.y; else if(aa.m != bb.m) return aa.m < bb.m; return aa.d < bb.d; } int main(){ scanf("%d/%d/%d",&a,&b,&c); check(c,a,b); check(c,b,a); check(a,b,c); sort(s,s+cnt,cmp); for(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) continue; printf("%d-%02d-%02d\n",s[i].y,s[i].m,s[i].d); } return 0; }