There are two ways to calculate leap years:
1) Divisible by 4 but not divisible by 100
2) Divisible by 400
#include <stdio.h>
int main()
{
int year ;
printf("请输入年份: ");
scanf("%d", &year);
if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
{
printf("输入的 %d 年是闰年", year);
}
else
{
printf("输入的 %d 年是平年", year);
}
return 0;
}