PTA

 #include<stdio.h>
int main() {
int year,month,day,cnt,flag;
flag = ;
scanf("%4d/%2d/%2d",&year,&month,&day);
if((year% == && year% != ) || (year% == ))
flag = ;
if(month == )
cnt = day;
if(month == )
cnt = + day;
if(month == )
cnt = + + day + flag;
if(month == )
cnt = + + + day + flag;
if(month == )
cnt = + + + + day + flag;
if(month == )
cnt = + + + + + day + flag;
if(month == )
cnt = + + + + + + day + flag;
if(month == )
cnt = + + + + + + + day + flag;
if(month == )
cnt = + + + + + + + + day + flag;
if(month == )
cnt = + + + + + + + + + day + flag;
if(month == )
cnt = + + + + + + + + + + day + flag;
if(month == )
cnt = + + + + + + + + + + + day + flag;
printf("%d",cnt);
}

简便的写法,用了数组和循环:

 #include<stdio.h>
int main() {
int year,month,day,cnt,flag,i;
int a[] = {,,,,,,,,,,,};
flag = ;
scanf("%4d/%2d/%2d",&year,&month,&day);
if((year% == && year% != ) || (year% == ))
flag = ;
for(i = ; i < month; i++)
cnt = cnt + a[i];
cnt = cnt + day;
if(month > && flag ==)
cnt++;
printf("%d",cnt);
}

c——闰年的更多相关文章

  1. javascript判断是否为闰年

    //判断年份year是否为闰年,是闰年则返回true,否则返回false function isLeapYear(year){ var a = year % 4; var b = year % 100 ...

  2. 2.4嵌套多重if else 的闰年判断以及bool变量的用法

    #include<stdio.h> #include<stdbool.h> int main() { int year; bool leap; //把leap定义为bool , ...

  3. 通过JAVA程序测试闰年

    首先简要介绍一下公历上规定的闰年:四年一闰,百年不闰,四百年再闰. 针对这一规则,简要的设计部分测试用例: 附(测试截图): 以下为该程序代码段: import javafx.application. ...

  4. 【Oracle】oracle中快速判断某一日期是闰年或平年

    )),' then '平年' else '闰年' end as isLeapYear from dual 第一步:取日期的年初日期:第二步:年初日期增加一个月即概念2月:第三步:取概念2月的最后一天的 ...

  5. System.DateUtils 2. IsInLeapYear 判断是否是闰年

    编译版本:Delphi XE7 function IsInLeapYear(const AValue: TDateTime): Boolean; implementation // 判断是否是闰年 f ...

  6. c#判断闰年

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. 用Java程序判断是否是闰年

    我们知道,(1)如果是整百的年份,能被400整除的,是闰年:(2)如果不是整百的年份,能被4整除的,也是闰年.每400年,有97个闰年.鉴于此,程序可以作以下设计: 第一步,判断年份是否被400整除, ...

  8. Python中判断是否为闰年,求输入日期是该年第几天

    #coding = utf-8 def getLastDay(): y = int(input("Please input year :")) m = int(input(&quo ...

  9. ytu 1059: 判别该年份是否闰年(水题,宏定义)

    1059: 判别该年份是否闰年 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 222  Solved: 139[Submit][Status][Web ...

  10. PHP日期操作类代码-农历-阳历转换、闰年、计算天数等

    <?php class Lunar { var $MIN_YEAR = 1891; var $MAX_YEAR = 2100; var $lunarInfo = array( array(0,2 ...

随机推荐

  1. "No entity found for query"(转)

    很久以前一直用EntityManager下getResultList()查询数据,即便一个数据亦是如此,所以要频繁的List.get(0).新接口getSingleResult()出现了,然后就开始频 ...

  2. Java之冒泡排序(升序)

    Java之冒泡排序 * 编辑者:鸿灬嗳 * 实现功能: 使用冒泡排序对数组:{25,24,12,76,101,96,28} 排序. */ package test05; public class Bu ...

  3. awk命令总结

    强大的文本处理工具,awk读取文件内容的每一行时,将对比该行是否与给定的模式相匹配,匹配则执行处理过程,否则对该行不处理. 序号 awk功能 例子 1 指定分隔符显示某几列   2 通过正则表达式取出 ...

  4. eureka注册中心列表页面加账号和密码

    正常情况下,注册中心服务启动后,页面是这样的,如下图所示 这样的话,如果注册中心不再内网地址下,有可能就会泄露所有的服务地址信息,增加受攻击的风险,针对这个问题咱们可以这样解决 首先注册中心pom.x ...

  5. DevExpress VCL Controls 2019发展路线图(No.3)

    [DevExpress VCL Controls下载] ExpressFlowChart 允许最终用户修改形状(v19.1) 允许开发人员以XML格式定义自定义形状(v19.1) 使用30多个新形状扩 ...

  6. Spring MVC流程

    这是spring mvc框架结构图,图片是很早在网上撸过来的,具体在哪忘了…… 早期学习Springmvc 并没有具体了解过,只知道这样用很爽,最近了解下基本结构流程及组件所在…… 执行流程 Spri ...

  7. IDEA2017 免费激活方法

    选择license server,然后填下面地址,选择一个就好. http://intellij.mandroid.cn/ http://idea.imsxm.com/ http://idea.ite ...

  8. java中的常用特殊字符

    1.转义字符反斜杠(\) 我们知道html中大都是双标签,如果在标签内想要输出带有标签结束符的文本都必须进行转义,html中是采用对应的字符替换,如<可用<替换 在java当中,我们要转义 ...

  9. Problem 3: Largest prime factor

    The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...

  10. MySQL存储过程中实现执行动态SQL语句

    sql语句中的任何部分都可以作为参数. DROP PROCEDURE if exists insertdata; delimiter //CREATE PROCEDURE insertdata(IN ...