日历表(第九周上机任务)。(不用掰手指头算了吧)

来源:互联网 发布:北京网络推手公司 编辑:程序博客网 时间:2024/05/01 14:13
/*   * Copyright (c) 2011, 烟台大学计算机学院   * All rights reserved.   * 文件名称:test.cpp   * 作 者:樊露露   * 完成日期:2012 年 10 月 26日   * 版 本 号:v1.0   *   * 输入描述:无   * 问题描述:输入年、月  * 程序输出:输出本月有多少天  * 问题分析:略   * 算法设计:略   */      #include <iostream>using namespace std;int main(){int year,month;cout<<"请输入年份:";cin>>year;cout<<"请输入月份:";cin>>month;if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)cout<<"本月有31天。"<<endl;if(month==4||month==6||month==9||month==11)cout<<"本月有30天。"<<endl;if(month==2){if((year%4==0 && year%100!=0)||(year%400==0))cout<<"本月有29天。"<<endl;elsecout<<"本月有28天。"<<endl;}return 0;}


 

 

心得体会:不用掰手指头算了。