1, leap years: where there is a leap year in the Gregorian calendar (February is 29th), the leap surplus (aged more than a leap. The lunar calendar is less than the year of the return year).
2, Leap Year Judgment method: four Years a leap, A.D. year can be divisible by 4 can not be divisible by 100, or can be divisible by 400 years.
3, because recently learning JavaScript, so now use javascript+html to implement this function, the code is as follows:
Run as follows:
4, it is simple to verify the following table shows:
User input |
Expected results |
Actual output |
2012 |
Leap |
Leap |
2013 |
Not a leap year |
Not a leap year |
2013abc |
Illegal input |
Illegal input |
Abch |
Illegal input |
Illegal input |
Test 1:
Test 2:
Test 3:
Test 4:
Code Gameover, I went to write parallel computing homework, TA sister goodbye ...
A leap year test program that detects whether the input is legitimate