判断1000年到2000年之间的闰年。
#include<stdio.h>
int main()
{
int year = 0;
for (year = 1000; year <= 2000; year++)
{
if (((year % 4 == 0) && (year %100 != 0)) || (year % 400 == 0))
{
printf("%d ", year);
}
}
ystem("pause");
return 0;
}
如果要计算闰年的个数。
include<stdio.h>
int main()
{
int year = 0;
int count = 0;
for (year = 1000; year <= 2000; year++)
{
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
{
printf("%d ", year);
count++;
}
}
printf("\ncount=%d\n", count);
system("pause");
return 0;
}
来源:CSDN
作者:jgm20475
链接:https://blog.csdn.net/jgm20475/article/details/78797200