提供一个清晰的c++版本...

#include <iostream>
using namespace std;
int main()
{
    int day= 0;
    int y,m;
    while(cin>>y>>m)
    {
        if(y%4)
            day = 28;
        else
            day = 29;
        switch(m)
        {
            case 2:
                cout<<day<<endl;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                cout<<30<<endl;
                break;
            default:
                cout<<31<<endl;
                break;
        }
    }
    return 0;
}

有用就点个赞吧