int dayNum;
int leapYear4, leapYear100, leapYear400;
int inputYear;
scanf("%d",&inputYear);
leapYear4 = (inputYear - 1)/4;
leapYear100 = (inputYear - 1)/100;
leapYear400 = (inputYear - 1)/400;
dayNum = (inputYear + leapYear4 - leapYear100 + leapYear400) %7;
switch (dayNum)
{
case 1 :
printf("Monday");
break;
case 2 :
printf("Tuesday");
break;
case 3 :
printf("Wednesday");
break;
case 4 :
printf("Thursday");
break;
case 5 :
printf("Friday");
break;
case 6 :
printf("Saturday");
break;
case 0 :
printf("Sunday");
break;
}
No comments:
Post a Comment