#include <stdio.h>
int main(void)
{
int y = 0;
int count = 0;
for (int y = 1000; y < 2001; y++)
{
//判断是不是闰年的方法:满足二者的年份
//1.能被4整除,不能被100整除是闰年
//2.能被400整除是闰年
if(y % 4 == 0)
{
if (y % 100 != 0)
{
printf("%d年是闰年\n", y);
count++;
}
}
if (y % 400 == 0)
{
printf("%d年是闰年\n", y);
count++;
}
}
printf("count = %d\n", count);
return 0;
}
//if((((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
C语言中打印闰年的方法
最新推荐文章于 2023-11-25 21:13:04 发布