#include <sio.h> #include<conio.h> #include<slib.h> int IsLeapYear(int); void main() { int i; int day; int year; int temp; int temp_i; long int Year_days = 0; int Year_Start = 1; int Per_Year_Days; int month_day[]={31,28,31,30,31,30,31,31,30,31,30,31,29};
printf("Please enter the year: "); scanf("%d",&year);
while(Year_Start < year) { if( IsLeapYear( Year_Start ) ) Per_Year_Days = 366; else Per_Year_Days = 365;
Year_days = Year_days Per_Year_Days; Year_Start ; }
for( temp = 1; temp <=12; temp ) { switch( temp ) { case 1: printf(" January(%d)\n",year); break; case 2: printf(" February(%d)\n",year); break; case 3: printf(" March(%d)\n",year); break; case 4: printf(" April(%d)\n",year); break; case 5: printf(" May(%d)\n",year); break; case 6: printf(" June(%d)\n",year); break; case 7: printf(" July(%d)\n",year); break; case 8: printf(" August(%d)\n",year); break; case 9: printf(" September(%d)\n",year); break; case 10: printf(" October(%d)\n",year); break; case 11: printf(" November(%d)\n",year); break; case 12: printf(" December(%d)\n",year); break; } i = Year_days % 7; printf("Mon Tue Wed Thu Fri Sat Sun\n"); if( i != 0 ) for( temp_i = 0; temp_i < i; temp_i ) printf(" "); day = 1; if( IsLeapYear(year) && temp == 2) while( day <= month_day[12] ) { if( day >1 ) if( Year_days % 7 == 0 ) printf("\n"); if( day >= 10 ) printf("%d ",day); else printf("%d ",day); Year_days ; day ; }
else while (day <= month_day[temp-1]) { if( day > 1 ) if( Year_days % 7 == 0 ) printf("\n"); if( day >=10 ) printf("%d ",day); else printf("%d ",day); Year_days ; day ; } printf("\n"); if( getch() == 'q' ) exit(0); } getch(); }
int IsLeapYear( int year ) { if ((year %4 == 0) && (year % 100 != 0) || (year % 400 == 0) ) return 1; else return 0; }
|