/*** @ Copyright 2011 Chunhui Wang *** wangchunhui@wangchunhui.cn */# include <stdio. h> int main () {printf ("\ t Perpetual calendar \ n "); printf ("\ t ------ Made by Chunhui Wang \ n"); int I, year, month; int day; // record the day of the week on the first day of each month. Int date; // Changes in the week of each year. Values of the year plus 1 and the LEAP plus 2 are calculated. Int a [13] = {, 28, 31, 30, 31, 30, 31, 30, 31}; // number of days of the month. Int Year [10000]; // the number of weeks on the first day of each Year. Year [1900] = 1; for (I = 1900; I <9999; I ++) {date = 1; if (I % 4 = 0) & (I % 100! = 0) | (I % 400 = 0) {date = 2;} Year [I + 1] = (Year [I] + date) % 7 ;} while (1) {printf ("Enter the year (for example, 1900):"); scanf ("% d", & year); printf ("Enter the month (for example, 01): "); scanf (" % d ", & month); a [2] = 28; if (year % 4 = 0) & (year % 100! = 0) | (year % 400 = 0) & (month> = 2) {a [2] = 29;} day = Year [year]; for (I = 1; I <month; I ++) {day = day + a [I];} day = day % 7; printf ("\ t % d month \ n", year, month ); printf ("\ t Monday \ t Tuesday \ t Wednesday \ t Friday \ t Saturday \ n"); for (I = 0; I <day; I ++) {printf ("\ t");} if (day = 0) printf ("\ t"); for (I = 0; I <a [month]; I ++) {printf ("% d \ t", I + 1); if (I + day) % 7 = 0) {printf ("\ n \ t") ;}} printf ("\ n") ;}return 0 ;}