zoukankan      html  css  js  c++  java
  • 12、计算某年的某个月有多少天

    计算某年的某个月有多少天

    计算某年的某个月有多少天

    程序代码如下:

    /*
        2017年3月12日19:13:29
        功能:计算某年的某个月有多少天
    */
    #include"stdio.h"
    void fun(int ,int );
    int main()
    {
        int year,month;
        printf("please input a year and a month,use space to divide that :");
        scanf("%d %d",&year,&month);
        fun(year,month);
    }
    void fun(int year,int mouth)
    {
        if(mouth == 1 ||mouth == 3 ||mouth == 5 ||mouth == 7 ||mouth == 8 ||mouth == 10 ||mouth == 12)
        {
            printf("%d年第%d个月有31天",year,mouth);
        }
        else if(mouth != 2)
        {
            printf("%d年第%d个月有30天",year,mouth);
        }
        else if(year % 4 == 0 || year % 400 == 0)
        {
            printf("%d年是闰年第2个月有29天",year,mouth);
        }
        else
            printf("%d年不是闰年第2个月有28天",year,mouth);
    
     }
    /*
        总结:
        在VC++6.0中显示的结果:
        ——————————————————————————————————
        please input a year and a month,use space to divide that :2016 2
        2016年是闰年第2个月有29天
        ——————————————————————————————————
    
    */
    

      

  • 相关阅读:
    xunjian.sh
    192.168.50.235配置
    自动备份并删除旧日志
    bg和fg命令
    linux之sed用法
    正则表示第二行,第二列
    linux下redis安装
    Hma梳理
    linux 系统监控、诊断工具之 lsof 用法简介
    java的基本数据类型有八种
  • 原文地址:https://www.cnblogs.com/wxt19941024/p/6538951.html
Copyright © 2011-2022 走看看