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天
        ——————————————————————————————————
    
    */
    

      

  • 相关阅读:
    游标+递归 查询 客户 子客户 查询财务信用
    导入EXCEL
    ftp读取txt数据并插入数据库
    查询通话时间报表
    4.10上午
    4.7下午
    4.6下午
    4.6上午
    4.5上午
    4.1下午
  • 原文地址:https://www.cnblogs.com/wxt19941024/p/6538951.html
Copyright © 2011-2022 走看看