当前位置:网站首页>Enter the year, month, and determine the number of days
Enter the year, month, and determine the number of days
2022-07-04 07:04:00 【cycy_ 0918】
#include<iostream>
using namespace std;
int year,month;
// Correct year
bool isRightYear(int year){
if(year>=0&&year<=9999)
return true;
return false;
}
// The month is correct
bool isRightMonth(int month){
if(month>=1&&month<=12)
return true;
return false;
}
// Is the year a leap year
bool isLeapYear(int year){
if(year%400==0||(year%100!=0&&year%4==0))
return true;
return false;
}
// Month type
int monthType(int month){
int days;
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:
if(isLeapYear(year))
{
days=29;break;
}
else{
days=28;break;
}
}
return days;
}
int main()
{
cin>>year>>month;
isRightYear(year);
isRightMonth(month);
cout<<monthType(month)<<endl;
return 0;
}
边栏推荐
- tars源码分析之3
- Google Chrome Portable Google Chrome browser portable version official website download method
- Uniapp applet subcontracting
- Selection (021) - what is the output of the following code?
- notepad++如何统计单词数量
- BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
- The important role of host reinforcement concept in medical industry
- win10微软拼音输入法输入文字时候下方不出现中文提示
- Redis interview question set
- Tar source code analysis Part 10
猜你喜欢
Industrial computer anti-virus
Selenium ide plug-in download, installation and use tutorial
The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D
Splicing plain text into JSON strings - easy language method
NLP literature reading summary
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Master-slave replication principle of MySQL database
Four sets of APIs for queues
Computer connects raspberry pie remotely through putty
Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture
随机推荐
How to input single quotation marks and double quotation marks in latex?
《剑指Offer》第2版——力扣刷题
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
Summary of June 2022
uniapp小程序分包
MySQL storage engine
《国民经济行业分类GB/T 4754—2017》官网下载地址
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Explain in one sentence what social proof is
2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
If there are two sources in the same job, it will be reported that one of the databases cannot be found. Is there a boss to answer
2022年6月小结
Label management of kubernetes cluster
tars源码分析之1
Vulhub vulnerability recurrence 76_ XXL-JOB
Selection (021) - what is the output of the following code?
The most effective futures trend strategy: futures reverse merchandising
Mysql 45讲学习笔记(六)全局锁
Splicing plain text into JSON strings - easy language method