Leap year calculation, enter the year to determine whether it is a leap year

Leap year calculation rules, can be divisible by 4 and not divisible by 100, or can be divisible by 400


#include <stdio.h>
#include <stdlib.h>
int main()
{
    
    
int year=0;
scanf_s("%d",&year);
if((year%4==0&&year%100!=0)||(year%400==0))
printf("这一年是闰年\n",year);
else
printf("这一年不是闰年\n",year);
system("pause");
return 0;
}

In this way, it is very convenient to judge which year is a leap year.

Guess you like

Origin blog.csdn.net/weixin_54748281/article/details/113574507