首先要知道到底什么要的年份才算是闰年呢?
闰年就是能被4整除但不能被100整除的年份,如2004年
代码展示:
include <stdio.h>
include <stdlib.h>
int main()
{
int year;
int count = 0;
for(int year = 1000;year< 2000;year++)
{
if(year % 4 == 0 && year % 100 != 0
{
conut++:
printf("%d\t",year);
}
}
printf("all leap year = %d\n",count);
System("pause");
return 0;
}
运行结果如下图所示: