求一个月有多少天,用switch完成。
输入格式:
输入两个整数,如2021 9,第一个表示年,第二个表示月,输出该月的天数。需要考虑闰年。如果月份错误,输出ERROR。
#include
using namespace std;
int main ()
{
int year,month;
cin>>year>>month;
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
cout<<31<
case 6:
case 9:
case 11:
cout<<30<
if((year%4==0&&year%100!=0)||year%400==0)
cout<<29<
cout<<28<
cout<<"ERROR"<
return 0;
}



