一、问题以及代码
/*
* 文件名称: ts.cpp
* 作 者:李甜甜
* 完成日期: 2017 年 4月 05日
* 版本号:v6.0
* 对任务及求解方法的描述部分:
* 输入描述: 无
* 问题描述:年份year月份monnt
* 程序输出:本月有几天
* 问题分析: 无
* 算法设计:
#include<iostream>
using namespace std;
int main()
{
int year,month;
cout<<"请输入年份和月份:";
cin>>year;
cin>>month;
if((year%4==0&&year%100!=0)||year%400==0)
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
cout<<"本月有31天"<<endl;
else if(month==4||month==6||month==9||month==11)
cout<<"本月有30天"<<endl;
else if(month==2)
cout<<"本月有29天"<<endl;
}
else
{
if(month==1||month==3||month==5||month==7||month==8||month==
c++实验3-本月有几天?
最新推荐文章于 2021-10-30 17:03:37 发布