please help me to finish my calendar!
it is a C++ program that you will
input the month and year.
then the output will be the calender
of the asked month and year!
int newYearDay(int year)
{
const newYear1901=2;
int elapseYear=year-1901;
int leapYear=elapseYear/4;
return(newYear1901+elapseYear+leapYear)%7;
}
int monthDays(int month, int year)
{
int days=0;
switch(month)
{
case 1:case 3:case 5:case 7:case 8:case 10:case 12:days=31;break;
case 4:case 6:case 9:case 11:days=30;break;
case 2:days=(year%4==0)?29:28;
}
return days;
}
int firstDay(int month, int year)
{
int elapseDay=newYearDay(year);
int i=1;
if(month>1)
{
for(;i<month;i++)
{
elapseDay=monthDays(month, year);
}
}
return elapseDay%7;
}