zoukankan      html  css  js  c++  java
  • 0031-闰年判断

    题目

    闰年判断
    难度级别: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;
    }
    作者:18西斯光剑
    出处:https://www.cnblogs.com/DARTH-VADER-EMPIRE/
    Copyright ©2018-2020 18西斯光剑
    All Rights Reserved.
  • 相关阅读:
    click event not triggered on bootstrap modal
    how to use datatables editor
    how to create modals with Bootstrap
    WebSite
    Spring Security OAuth 2开发者指南译
    security和oauth2.0的整合
    Spring Boot遇到的某些问题
    linux主机名莫名其妙变成了bogon,并解决修改为localhost
    Getway网关管理ZUUL
    feign中的hytrix和turbin配置
  • 原文地址:https://www.cnblogs.com/DARTH-VADER-EMPIRE/p/9491879.html
Copyright © 2011-2022 走看看