闰年: 四年一闰,百年不闰,四百年再闰。
代码如下:
#include<stdio.h>
#include<windows.h>
#pragma warning(disable:4996)
void Leapyear(int x)
{
if (0 == x % 4 && 0 != x % 100||0 == x % 400){
//当所需判断的年份可以整除4且不能整除100或者可以整除400的是闰年
printf("%d 是闰年\n");
}
else{
printf("%d 不是闰年 \n");
}
}
int main()
{
int x ;
printf("请输入你的所需要的判断的年份:\n");
scanf("%d", &x);
Leapyear(x);
system("pause");
return 0;
}