C language, determine whether it is a leap year

A leap year is a year that is divisible by 4 but not 100 or divisible by 400!

And (&&): Both conditions must be correct

or (||): Two conditions, one of which is correct is correct

#include<stdio.h>
int main()
{
	int year;
	printf("输入年份");
	scanf("%d", &year);
	if ((year % 10 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		printf("%d是闰年", year);
	}
	else printf("%d不是闰年", year);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_62247560/article/details/124992152