原题链接:P5711 闰年判断
其实这题并不难,只是对于闰年的判断忘记了,因此搜了一下闰年的判断条件
如果是世纪年(世纪年就是能被100整除的年份)能被400整除的就是闰年,
如果是非世纪年,能被4整除且不能被100整除的就是闰年。
贴上代码:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int x;
scanf("%d",&x);
if(x % 100 == 0)
{
if(x % 400 == 0)
printf("1\n");
else
printf("0\n");
}
else
{
if(x % 4 == 0 && x % 100 != 0)
printf("1\n");
else
printf("0\n");
}
return 0;
}