Leap Year Judgment method:
1. Years that can be evenly divisible;
2. Year that can be divisible by 4 but not divisible by the same .
A leap year is one that satisfies either of these conditions.
Here are three different forms
The first type:
#include <stdio.h>int main () {int year,leap,count=0; for (year=1000;year<=2000;year++) {if (year%4==0) {if (year%100==0) {if (year%400==0) leap=1;/* Years that can be divisible by 400 are leap year */Else leap=0; The year that the else leap=1;/*year can be divisible by 4 and cannot be divisible by 100 is leap years */} else leap=0; if (leap) printf ("%d", year,count++);/* Output 1000-2000 all years and calculate the total number of leap year */} if (count%10==0) printf ("\ n");/* 10 Number of lines per output */Prin TF ("\ncount=%d", count); return 0;}
The second type:
#include <stdio.h>int main () {int year,count=0;for (year=1000;year<=2000;year++) {if (year%4==0) {if (year%100 !=0) printf ("%d", year,count++),/*year can be divisible by 4 and not divisible by 100 is a leap year */}if (year%400==0) printf ("%d", year,count++);/* Years that can be divisible by 400 are leap year */}printf ("\ncount=%d", count);/* Output 1000-2000 is the total number of leap years */return 0;}
The third type:
#include <stdio.h>int main () {int yaer,count=0; for (year=1000;year<=2000;year++) {if (year%4==0&& year%100!=0| | year%400==0) printf ("%d", year,count++); /* Use with operations and/or operations to determine leap year */} printf ("\ncount=%d", count);/* Output 1000-2000 is the total number of leap years */return 0;}
This is known as the "four Years a leap, a century does not leap, 400 years to leap" Leap year algorithm program. But for a large number of years, if the year can be divisible by 3200, and divisible by 172800 is a leap year, due to the leap years between 1000-2000, this program does not consider this.
This article is from the "Materfer" blog, make sure to keep this source http://10741357.blog.51cto.com/10731357/1698584
C-language judgment leap year between 1000-2000 years