本月几天

来源:互联网 发布:迅龙数据恢复软件 编辑:程序博客网 时间:2024/05/01 07:03
  1. /*     
  2. *Copyright (c) 2012, 烟台大学计算机学院      
  3.  * All rights reserved.      
  4.  * 作    者:王俊
  5.  * 完成日期:2012 年 10 月 29 日      
  6.  * 版 本 号:v1.0      
  7.   * 输入描述:略      
  8. * 问题描述:略    
  9. * 程序输出:略   
  10. * 问题分析:略   
  11. * 算法设计:    
    */          #include<iostream>using namespace std;int main(){int year,month,day;cout<<"Please entre year  month:";cin>>year>>month;switch(month){case 1:day=31;break;case 2:if(year%4==0&&year%100!=0||year%400==0)   {   day=29;break;   }else{day=28;break;}case 3:day=31;break;case 4:day=30;break;case 5:day=31;break;case 6:day=30;break;case 7:day=31;break;case 8:day=31;break;case 9:day=30;break;case 10:day=31;break;case 11:day=30;break;case 12:day=31;break;}cout<<"本月有"<<day<<"天"<<endl;return 0;}

    运行结果:  
原创粉丝点击