本月有几天
来源:互联网 发布:mac jdk 默认安装路径 编辑:程序博客网 时间:2024/05/02 04:47
#include<iostream>using namespace std;int main(){int year,month;cout<<"输入年、月:"<<endl;cin>>year>>month;if(year%4==0 && year%400==0){switch(month){case 1:cout<<"本月有31天"<<endl; break;case 2:cout<<"本月有29天"<<endl;break;case 3:cout<<"本月有31天"<<endl; break;case 4:cout<<"本月有30天"<<endl; break;case 5:cout<<"本月有31天"<<endl; break;case 6:cout<<"本月有30天"<<endl; break;case 7:case 8:cout<<"本月有31天"<<endl; break;case 9:cout<<"本月有30天"<<endl; break;case 10:cout<<"本月有31天"<<endl; break;case 11:cout<<"本月有30天"<<endl; break;case 12:cout<<"本月有31天"<<endl; break;}}else{switch(month){case 1:cout<<"本月有31天"<<endl; break;case 2:cout<<"本月有28天"<<endl;break;case 3:cout<<"本月有31天"<<endl; break;case 4:cout<<"本月有30天"<<endl; break;case 5:cout<<"本月有31天"<<endl; break;case 6:cout<<"本月有30天"<<endl; break;case 7:case 8:cout<<"本月有31天"<<endl; break;case 9:cout<<"本月有30天"<<endl; break;case 10:cout<<"本月有31天"<<endl; break;case 11:cout<<"本月有30天"<<endl; break;case 12:cout<<"本月有31天"<<endl; break;}}return 0;}
#include<iostream>using namespace std;int main(){int year,month,days;cout<<"输入年、月:"<<endl;cin>>year>>month;switch(month){case 1:case 3:case 5:case 7: case 8:case 10:case 12:days=31;break;case 4:case 6:case 9:case 11:days=30;break;case 2:if(year%4==0 && year%400==0)days=29;elsedays=28;break;}cout<<"本月有:"<<days<<"天"<<endl;return 0;}
心得体会:与老师的思路相比,我的还太显稚嫩。借鉴、学习、会越来越好的~
- 本月有几天?
- 本月有几天
- 本月有几天
- 本月有几天?
- 计算本月有几天
- 本月有几天
- 本月有几天
- 本月有几天,亲
- 本月有几天
- 本月有几天
- 求本月有几天
- 本月有几天
- 本月有几天
- 本月有几天
- 本月有几天
- 本月有几天
- 得本月有几天
- 本月有几天
- AppBar与Panel
- 设计模式之观察者模式
- 关于inline函数
- 数组与Object的关系及其反射类型
- 数据库连接池的配置
- 本月有几天
- Minimum Transport Cost(dijkstra输出路径)
- Android--遍历SQLite数据库下的所有表名
- 静态链表
- 划分树
- 2013年01月21日 工作总结
- 蟋蟀的xss淫荡教程之如何劫持OSC用户账号
- perl模板的应用:随机排序:随机不放回取样
- LINUX-C成长之路(七):数组与指针