#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void leap_year(int x)
{
if (((x % 4 == 0) && (x % 100 != 0)) || (x % 400 == 0))
{
printf("%d 是闰年\n", x);
}
else
printf("%d 不是闰年\n", x);
}
int main()
{
int year = 0;
printf("请输入年份: ");
scanf("%d", &year);
leap_year(year);
return 0;
}
结果展示:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200822162814398.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NjU4MzM5,size_16,color_FFFFFF,t_70#pic_center)