Write a function to determine year is not a leap year

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_45663523/article/details/102456272

1, to implement a function to determine year is not a leap year.
2, the idea: simultaneously not divisible by 4 is a leap year divisible by 100; divisible by 400 is a leap year.
3, program:

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
void discriminant_fun(year);
int main()
{
	printf("请输入年份:");
	int year;
	scanf("%d", &year);
	discriminant_fun(year);
 
 system("pause");
 return 0;
}
void discriminant_fun(year)
{
	if (year % 4 == 0 && year % 100 != 0)
	{
		printf("%d为闰年!", year);
	}
	else if (year % 400 == 0 )
	{
		printf("%d为闰年!", year);
	}
	else
		printf("%d不为闰年!", year);
}

4 results:
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_45663523/article/details/102456272