As is known to all, we have two formats to denote a specific date: MM/DD/YY or YY/MM/DD. We supposed the years discussed below are years in 20YY.
Now you are given a string representing the date. If there is only one possible date it can fit in with format of "MM/DD/YY" or "YY/MM/DD", output the date in the format of "month date, year" (as can be seen in the second sample). Otherwise, output the days between the two different dates it might be.
题意:
给一个合法的日期,可能是MM/DD/YY or YY/MM/DD,如果是其中的一种,则输出"month date, year",
否则,输出两个日期的差值,若差值为0,输出个日期
Otherwise, output the days between the two different dates it might be.
#include
using namespace std;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int leap_day[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
char month[13][10]={"","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" ,"December"};
bool leap(int y)
{
if(y%4==0&&y%100!=0||y%400==0)
return 1;
return 0;
}
bool check(int y,int m,int d)
{
if(y<0||y>99) return 0;
if(m<1||m>12) return 0;
if(d<1||d>31) return 0;
if(leap(y+2000))
{
if(d>leap_day[m]) return 0;
}
else
if(d>day[m]) return 0;
return 1;
}
long long sum(int y,int m,int d)
{
long long sum=0;
for(int i=0;i