/*
*Copyright (c) 2016 烟台大学计算机学院
*All rights reserved.
*文件名称:a.cpp
*作者:刘磊
*完成日期:2016年3月1日
*版本号:v1.0
*
*问题描述:输入年份和月份,输出本月有几天。
*输入描述:两个数,代表年份和月份。
*程序输出:输出本月有几天。
*/
#include <iostream>
using namespace std;
int main()
{
int year,month;
double a,b,c;
cin>>year>>month;
a=year%4;
c=year%100;
b=year%400;
if(((a==0) && (c!=0)) || (b==0))
{
switch(month)
case 1:
case 3:
case 5:
case 7:
case 9:
case 11:
{
cout <<"本月有31天"<<endl;
break;
}
switch(month)
case 4:
case 6:
case 8:
case 10:
case 12:
{
cout <<"本月有30天"<<endl;
break;
}
switch(month)
case 2:
{
cout <<"本月有29天"<<endl;
break;
}
}
else
{
switch(month)
case 1:
case 3:
case 5:
case 7:
case 9:
case 11:
{
cout <<"本月有31天"<<endl;
break;
}
switch(month)
case 4:
case 6:
case 8:
case 10:
case 12:
{
cout <<"本月有30天"<<endl;
break;
}
switch(month)
case 2:
{
cout <<"本月有28天"<<endl;
break;
}
}
return 0;
}
本月有几天
最新推荐文章于 2021-05-17 10:43:35 发布