首先介绍一下闰年的概念:
普通年(不能被100整除的年份)能被4整除的为闰年。(如2004年就是闰年,1999年不是闰年);
世纪年(能被100整除的年份)能被400整除的是闰年。(如2000年是闰年,1900年不是闰年);
//四年一闰,百年不闰,四百年再闰
#include <stdio.h>
int main()
{
int count = 0;
int year = 0;
for (year = 1000; year <= 2000; year++)
{
if (year % 4 == 0)
{
if (year % 100 != 0)
{
printf("%d ", year);
count++;
}
}
if (year % 400 == 0)
{
printf("%d ", year);
count++;
}
}
printf("\n count = %d\n", count);
return 0;
}