# Include "iostream" using namespace STD; int main () {int M, D, monthmax, Y; while (1) {cout <"Enter the year :"; cin> Y; cout <"Enter the month:"; CIN> m; cout <Endl; // determine the year and month if (Y % 4 = 0 | (Y % 100 = 0 & Y % 400 = 0 )) // leap year {If (M = 1 | M = 3 | M = 5 | M = 7 | M = 8 | M = 10 | M = 12) monthmax = 31; If (M = 2) monthmax = 29; If (M = 4 | M = 6 | M = 9 | M = 11) monthmax = 30;} If (Y % 4! = 0) // year {If (M = 1 | M = 3 | M = 5 | M = 7 | M = 8 | M = 10 | M = 12) monthmax = 31; If (M = 2) monthmax = 28; If (M = 4 | M = 6 | M = 9 | M = 11) monthmax = 30;} // obtain the number of weeks in week 1 If (M = 1 | M = 2) {M + = 12; // The first month is counted as the 13 months of the previous year, and the second month is counted as the 14 months of the previous year y --;} d = (2 + 2 * m + 3 * (m + 1) /5 + Y/4-y/100 + Y/400) % 7; // calculate the number of week 1 of this month if (D = 0) {d = 7 ;} // output calendar {// Title module if (M = 13) {cout <"ad" <Y + 1 <"1st Calendar" <Endl;} If (M = 14) {cout <"ad" <Y + 1 <"2nd Calendar" <Endl;} If (M! = 13 & M! = 14) {cout <"ad" <Y <"year" <m <"month calendar" <Endl ;}} cout <"1 2 3 4 5 6 7" <Endl <"==================== ===== "<Endl; for (INT I = 1; I <= D-1; I ++) {cout <";} For (Int J = 1; j <= monthmax; j ++) {If (j <10) {cout <"" <j <"";} If (j> = 10) {cout <"" <j <"" ;}if (J + D-1) % 7 = 0) {cout <Endl ;} if (j = monthmax) {cout <Endl ;}}}