题解 | #获得月份天数#
获得月份天数
http://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
提供一个清晰的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;
}
有用就点个赞吧