一月有几天

来源:互联网 发布:软件项目 编辑:程序博客网 时间:2024/05/02 00:13
/*      * Copyright (c) 2012, 烟台大学计算机学院       * All rights reserved.       * 作    者:杨绍宁   * 完成日期:2012 年 10 月 28日       * 版 本 号:v1.0       * 输入描述:本月有几天    * 问题描述:输入年份、月份,即可求得本月一共多少天     * 程序输出:本月一共多少天    * 问题分析:先判断是否为闰年,然后根据所输入的月份进行输出    * 算法设计:       */   #include <iostream>#include <Cmath>using namespace std;int main(){int year,month;cout<<"请输入year、month的值:";cin>>year>>month;if(month==1 || month==3|| month==5||month==7||month==8||month==10||month==12)cout<<"该月有31天"<<endl;else if(month==4||month==6||month==9||month==11)    cout<<"该月有30天"<<endl;else{if(year%4==0 &&year%100!=0||year%400==0)cout<<"该月有29天"<<endl;elsecout<<"该月有28天"<<endl;}     cout<<endl; return 0;}


结果:

感受:加油!!!

原创粉丝点击