标签:闰年 item namespace name width 运行 puts 其他 mes
| 闰年判断 |
| 难度级别:A; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B |
|
试题描述
|
|
给定一个正整数 n 表示年份,判断该年是否为闰年,是闰年输出 “yes”,不是闰年输出 “no”。
|
|
输入
|
|
一个正整数 n
|
|
输出
|
|
按题目要求输出
|
|
输入示例
|
|
2014
|
|
输出示例
|
|
no
|
|
其他说明
|
|
数据范围: n 在 int32 范围内。
|
分支题,考虑到类似于1900年的情况,即n%400,就行了。
代码:
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
if((!(n%4)&&n%100)||(!(n%400))) printf("yes");
else printf("no");
return 0;
}
标签:闰年 item namespace name width 运行 puts 其他 mes
原文地址:https://www.cnblogs.com/DARTH-VADER-EMPIRE/p/9491879.html