当前位置:网站首页>输入年份、月份,确定天数
输入年份、月份,确定天数
2022-07-04 06:58:00 【cycy_0918】
#include<iostream>
using namespace std;
int year,month;
//年份正确
bool isRightYear(int year){
if(year>=0&&year<=9999)
return true;
return false;
}
//月份正确
bool isRightMonth(int month){
if(month>=1&&month<=12)
return true;
return false;
}
//年份是否为闰年
bool isLeapYear(int year){
if(year%400==0||(year%100!=0&&year%4==0))
return true;
return false;
}
//月份类型
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;
}
边栏推荐
- Novel website program source code that can be automatically collected
- Mobile adaptation: vw/vh
- Boast about Devops
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- Modify TCP timestamp to optimize transmission performance
- Can the out of sequence message complete TCP three handshakes
- Design of test cases
- Introduction to spark core components
- Background and current situation of domestic CDN acceleration
- What is the use of cloud redis? How to use cloud redis?
猜你喜欢
期末周,我裂开
MySQL storage engine
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
《剑指Offer》第2版——力扣刷题
图的底部问题
颈椎、脚气
Wechat applet scroll view component scrollable view area
A new understanding of how to encrypt industrial computers: host reinforcement application
Set JTAG fuc invalid to normal IO port
随机推荐
The difference between synchronized and lock
How does the inner roll break?
NLP-文献阅读总结
内卷怎么破?
响应式——媒体查询
Google Chrome Portable Google Chrome browser portable version official website download method
Centos8 install mysql 7 unable to start up
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
Tar source code analysis Part 2
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
About how idea sets up shortcut key sets
Explain in one sentence what social proof is
Tar source code analysis Part 7
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
Wechat applet scroll view component scrollable view area
2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
leetcode825. Age appropriate friends
MySQL 45 lecture learning notes (x) force index
What is the "relative dilemma" in cognitive fallacy?