Int main ()
{
Int year, day, leapyear=0, I, whichday;
The scanf (" % d ", & amp; Year);
For (I=1900; i<=year; I++)
{
If ((I %==0 400) | | ((I % 100!=0) & amp; & (I % 4==0))) leapyear +=1;/* find out 1900 to target between several leap year */
}
Day=(((year 1899) * 365 + leapyear) - (31 + 30 + 3 + 31 + 30 + 31 + 30 + 31)) % 7;/* calculated from January 1, 1900 (Monday) to the target in April 30, a total of how many days, and the target in April 30 for week */
If (day==7) whichday=14;
The else whichday=14 - day;
Printf (" % d ", whichday);
return 0;
}
Have the following questions:
1 week to solve the problems in the C language is generally known by default on January 1, 1900 for Monday?
2. Why can take over operations answers for 7
If (day==7) whichday=14;
The else whichday=14 - day;
CodePudding user response:
My personal understanding should be output day-of-week, such as specific for more than 100 days, rather than the output? So they will take care of week, directly calculate leap year to calculate the number of days before may plus the 14CodePudding user response:
For more than 7 take seven, could not possible for a value between 0 ~ 6;Usually fixed a date of the week, so there is a reference, the day of the week is an anticipation heavy relative time, then have a reference; Such as January 1, 1900 is on Monday
CodePudding user response:
So are there any wrong in the code but run on and there is nothing wrong withCodePudding user response: