- <pre class="cpp" name="code">/*
- *Copyright (c) 2016,烟台大学计算机与控制工程学院
- *All rights reserved.
- *文件名称:http.cpp
- *作 者:孙超
- *完成日期:2016年3月29日
- *版 本 号:v1.0
- *
- *问题描述:编写程序,输入年份和月份,输出本月有多少天:
- *样例输入1;2004 2,
- *输出结果1:本月29天
- *样例输入2;2010 4,
- *输出结果2:本月30天
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- int year,month;
- cin>>year>>month;
- switch(month)
- {
- case 4:
- case 6:
- case 9:
- case 11:
- cout<<"本月30天"<<endl;
- break;
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- cout<<"本月31天"<<endl;
- break;
- case 2:
- if(year%4==0&&year%100!=0||year%400==0)
- {
- cout<<"本月29天"<<endl;
- break;
- }
- else
- {
- cout<<"本月28天"<<endl;
- break;
- }
- default:
- break;
- }
- return 0;
- }
第三周项目二
最新推荐文章于 2023-05-18 10:46:37 发布