目录
1、闰年的判断方法
如果是4的倍数,该年份一般是闰年;
如果不是4的倍数,该年份一般是平年。
公历年份是整百数的必须是400的倍数才是闰年,反之则是平年
2、 1000-2000年之间的闰年
#include<stdio.h>
#include<stdlib.h>
int main()
{
int count=0;
for (int i = 1000; i <= 2000; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
{
printf("%d ", i);
count++;
}
}
printf("\n%d", count);
return 0;
}
3、某年是否为闰年
#include<stdio.h>
int Isyear(int year)
{
if (year % 400 == 0 || ((year / 4 == 0) && year / 100 != 0))
/*f (((year % 4 == 0) && year % 100 != 0) || year % 400 == 0)*/
{
return 1;
}
return 0;
}
int main()
{
int year = 0;
scanf("%d", &year);
int ret = Isyear(year);
if (ret == 1)
{
printf("%d年是闰年\n", year);
}
else
{
printf("%d年不是闰年\n", year);
}
return 0;
}