小明刚刚学习了每月有多少天,以及如何判断平年和闰年,想到可以使用编
程方法求出给定的月份有多少天。你能做到吗?
#include <iostream>
using namespace std;
int main(){
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},a,b,s=0;
cin>>a>>b;
if(a%4==0 && a%100!=0 || a%400==0){
m[2]=29;
}
if(b>12){
cout<<"error"<<endl<<0;
return 0;
}
s+=m[b];
cout<<s;
return 0;
}