P5711 【深基3.例3】闰年判断
题目
描述
输入一个年份(大于 1582 的整数 ),判断这一年是否是闰年,如果是输出 1,否则输出 0。
输入输出样例
输入 | 输出 |
---|---|
2000 |
1 |
解答
#include<iostream>
using namespace std;
int a;
int main()
{
cin>>a;
if(a%4==0 && (a%100!=0 || a%400==0))
cout<<1;
else
cout<<0;
return 0;
}
博主的个人网站:https://codespark.cn/