#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int is_leap_year(int y)
{
return (((y % 4 == 0) && (y / 100 != 0)) || (y % 400 == 0));
}
int main()
{
int year = 0;
printf("请输入年份:>");
scanf("%d", &year);
int res = is_leap_year(year);
if (res == 1)
{
printf("是闰年\n");
}
else
{
printf("不是闰年\n");
}
system("pause");
return 0;
}
实现一个函数判断year是不是闰年。
最新推荐文章于 2022-06-28 15:39:34 发布