您的位置:首页 > 其它

第三周项目:本月有几天?

2016-04-05 20:37 357 查看
#include<iostream>
using namespace std;
int main()
{
i
4000
nt  year, month, days;
cout << "请输入年、月: ";
cin >> year >> month;
if(year%4==0 && year%100!=0 ||year%400==0)
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days = 31;
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;
case 2:
days = 29;

}
}
else
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days = 31;
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;
case 2:
days =28;
}
}
cout<<year<<"年"<<month<<"月共有"<<days<<"天。"<<endl;
return 0;
}
<img src="https://img-blog.csdn.net/20160405203656688?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: