Topic Link: Click to open the link
The main topic describes a slight pit is the 1752.9.2 ago the United States date with the old algorithm, 9.14 after the new algorithm
The other 1.1.1 is what setup is for Saturday. The number of days needed to be reduced by 2
Lunar Date =year*365+m[month]+day+year/4-2
New Calendar Date =year*365+year/4-year/100+year/400+m[month]+day+1752/100-1752/400-11-2
=year*365+year/4-year/100+year/400+m[month]+day
February written fabruary half a day did not see it.
Code:
#include <iostream>
#include <cstdio>
using namespace Std;
int mm[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int m[12]={0,31,59,90,120,151,181,212,243,273,304,334};
Char mn[12][20]={"January", "February", "March", "April", "may", "June", "July", "August", "September", "October", " November "," December "};
Char dn[7][20]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
BOOL Leapyear (int y) {
if (y<=1752)
return y%4==0;
Return ((y%4==0) && (y%100!=0) | | y%400==0;
}
BOOL IsValid (int y,int m,int d) {
if (!m| |! d| |! Y
return 0;
if (m>12)
return 0;
if (y==1752&&m==9&&d>2&&d<14)
return 0;
if (Leapyear (y)) {
if (m==2) {
if (d>29)
return 0;
}
else if (D>mm[m-1])
return 0;
}
else if (D>mm[m-1]) {
return 0;
}
return 1;
}
int main ()
{
Freopen ("Input.txt", "R", stdin);
int y,m,d;
int totday,curday;
while (cin>>m>>d>>y,m| | d| | Y) {
if (!isvalid (y,m,d)) {
printf ("%d/%d/%d is a invalid date.\n", m,d,y);
Continue
}
if (y<1752| | (y==1752&&m<9) | | (y==1752&&m==9&&d<=2)) {
Totday= (y-1) *365+ (y-1)/4;//-(y-1)/100+ (y-1)/400;
TOTDAY+=M[M-1];
Totday+=d;
if (y%4==0&&m>2) {
totday++;
}
totday-=2;
curday=totday%7;
}
else{
Totday= (y-1) *365+ (y-1)/4-(y-1)/100+ (y-1)/400;
Totday+=m[m
-1];
Totday+=d;
if (Leapyear (y) &&m>2) {
totday++;
}
curday=totday%7;
}
if (curday==0)
curday=7;
cout<<curday<<endl;
printf ("%s%d,%d is a%s\n", mn[m-1],d,y,dn[curday-1]);
}
return 0;
}