[C语言]显示1000年到2000年之间所有的闰年
什么是闰年
普通年(不能被100整除的年份)能被4整除的为闰年。(如2004年就是闰年,1999年不是闰年),
世纪年(能被100整除的年份)能被400整除的是闰年。(如2000年是闰年,1900年不是闰年),
即四年一闰,百年不闰,四百年再闰。
代码
#include<stdio.h>
#include<stdlib.h>
int main()
{
int year = 0, i = 0;
for (year = 1000; year <= 2000; year++)
{
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
printf("%7d", year);
i++;
if (i % 10 == 0)
{
printf("\n");
}
}
}
system("pause");
return 0;
}