include
include<stdio.h>
using namespace std;
// 函数leapYear
int leapYear(int y)
{
if(y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
return 1;
return 0;
}
// Function whatDay: Calculate the day of the month of a certain year is the day of the week
// Parameters: year-year, month-month
// Return value:
--7 means Monday to Sunday int whatDay (int year, int month)
{
// Please add code here to implement the function whatDay
/ ********** Begin /
int day = 1, week;
if ((month == 1) || (month == 2)) {/ January and February are regarded as the thirteen and fourteen months of the previous year /
month + = 12;
year--;
}
if ((year <1752) || ((year == 1752) && (month <9) )
|| ((year == 1752) && (month == 9) && (day <3))) / Judge whether it is before September 3, 1752 /
week = (day + 2 month + 3 (month + 1) / 5 + year + year / 4 +5)% 7; / formula before September 3, 1752 /
else week = (day + 2 month + 3(month + 1) / 5 + year + year / 4-year / 100 + year / 400)% 7; / formula after September 3, 1752 /
week ++;
return week;
/ ********* End ********** /
}
int main ()
{
int y, m, xq; // year, month, day of the week
cin >> y >> m; // enter year and month
xq = whatDay (y, m); // calculate day of the week
cout << y << "year" << m << "Month 1 is a week"; // output week
if (xq == 7)
cout << "day" << endl;
else
cout << xq << endl;
return 0;
}