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. Python_Mix*异常处理

    name 结果为: Traceback (most recent call last): #错误的追溯 File "C:/Users/Mi/PycharmProjects/untitled/ ...

  2. CSS3-2

    倒圆角 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  3. spring websocket报错:No matching message handler methods.

    错误信息: [org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler]-[DEBUG] No ...

  4. 【webpack学习笔记】a01-基础构建

    webpack基于nodejs环境运行,首先确认已经安装了node.js. 基础构建流程 新建一个文件夹,这个就是你项目的根目录. 在命令行中使用npm init命令初始化npm,会得到一个 ==pa ...

  5. sql查询,更新,删除,操作。

    UPDATE ht_plan_triptime pptSET ppt.lock_status = '1'WHERE ppt.lock_status <> '1'    AND ppt.pl ...

  6. centos7 无界面静默安装 oracle

    环境准备 Centos7.3.64  64位   这里使用的是阿里云 ECS主机(1核,2G内存,40G硬盘) Oracle 11g R2 64位安装介质(版本11.2.0.1)下载地址:http:/ ...

  7. centos7 下安装mysql教程

    最近要在centos服务器上配置环境,在部署mysql的时候,碰到各种各样的问题,网上博客文章也是有各种坑,目前发现一个比较好的博客: https://blog.csdn.net/xiaomojun/ ...

  8. 查询总耗CPU最多与平均耗CPU最多的SQL语句

    总耗CPU最多的前20个SQL total_worker_time AS [总消耗CPU 时间(ms)],execution_count [运行次数], qs.total_worker_time AS ...

  9. Python常用数据类型

    一 .列表 name = ['zhangshan', 'lishi', 'wangwu']# 列表赋值 name.append('liujun')# 增,默认增加到最后位置 name.insert(1 ...

  10. C# 连蒙带骗不知所以然的搞定USB下位机读写

    公司用了一台发卡机,usb接口,半双工,给了个dll,不支持线程操作,使得UI线程老卡. 懊恼了,想自己直接通过usb读写,各种百度,然后是无数的坑,最终搞定. 现将各种坑和我自己的某些猜想记录一下, ...