题解 | #判断闰年#
判断闰年
https://www.nowcoder.com/practice/a7bcbe3cb86f435d9617dfdd20a16714
#include <stdio.h>
//因为能被400整除,或者能被4整除但不能被100整除才是闰年
int main()
{
int n = 0;
scanf("%d", &n);
if (n > 0 && n <= 2018)
{
if ((n % 4) == 0&&(n % 100) != 0)
{
printf("yes");
}
else if(n%400==0)
{
printf("yes");
}
else
{
printf("no");
}
}
else
{
printf("请输入正确的年份");
}
return 0;
}
查看22道真题和解析