Int main ()
{
Int a, b;
Printf (" input year: ");
The scanf (" % d ", & amp; A);
If (a % 4==0)
{
If (a % 100==0)
{
If (a % 400==0)
B=1;
The else
b=0;
}
The else
B=1;
}
The else
b=0;
If (b)
Printf (" leap year ");
The else
Printf (" is not a leap year ");
Return 0;
}
CodePudding user response:
Is that it can be divided exactly by 4, but cannot be divided exactly by 100, or a divisible by 400 year is a leap year, know this is ok, the calendar thing mathematical principles may be more complex,CodePudding user response:
They are written out, you still don't understand, fresh,If you want to ask a leap year calendar explanation, it had to go to find astronomical professional,
CodePudding user response:
Int year=0;
The scanf (" % d ", year);
If ((year % 4==0 & amp; & Year % 100!=0) | | (400 year %==0))
Printf (" % d is a leap year, year);
The else
Printf (" % d is not a leap year, year);
CodePudding user response:
A few simple the if condition is nested, readable!Or, change b to bool quantity will be more easy to read
CodePudding user response:
In 400 only 97 leap years,If in multiples of four years, it is not a leap year,
If it is a multiple of 4, may be a leap year, if in multiples of 100, also must be in multiples of 400 is a leap year,
CodePudding user response:
Is can be divided exactly by 4, but cannot be divided exactly by 100, or divisible by 400 year is a leap year