P5716 【深基3.例9】月份天数

P5716 【深基3.例9】月份天数

在这里插入图片描述

#include<iostream>
using namespace std;

int main(void)
{
    
    
    //p5716
    int y,m;
    cin>>y>>m;
    switch(m){
    
    

        case 1:case 3: case 5: case 7: case 8: case 10: case 12:
            cout<<31<<endl;
            break;

        case 4: case 6: case 9: case 11:
            cout<<30<<endl;
            break;

        case 2:


            //前两个条件先判断  
            if((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
            {
    
    
                cout<<29<<endl;
            }
            else
            {
    
    
                cout<<28<<endl;
            }

            break;
        default:break;

    }

    system("PAUSE");

    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44653420/article/details/121503218
今日推荐