当前位置:网站首页>输入年份、月份,确定天数
输入年份、月份,确定天数
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;
}
边栏推荐
- 【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
- A new understanding of how to encrypt industrial computers: host reinforcement application
- 用于压缩视频感知增强的多目标网络自适应时空融合
- Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
- Analysis of tars source code 1
- tars源码分析之4
- centos8安装mysql.7 无法开机启动
- How can the old version of commonly used SQL be migrated to the new version?
- Mysql 45讲学习笔记(十)force index
- tars源码分析之9
猜你喜欢

Fundamentals of SQL database operation

用于压缩视频感知增强的多目标网络自适应时空融合

Vulhub vulnerability recurrence 76_ XXL-JOB

Responsive - media query

2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?

the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘

NLP-文献阅读总结

Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and

Responsive mobile web test questions

2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
随机推荐
What is a spotlight effect?
[thread pool]
How can the old version of commonly used SQL be migrated to the new version?
tars源码分析之4
tars源码分析之2
Tar source code analysis 8
ABCD four sequential execution methods, extended application
《国民经济行业分类GB/T 4754—2017》官网下载地址
How to share the source code anti disclosure scheme
Campus network problems
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
在已经知道表格列勾选一个显示一列
抽奖系统测试报告
MySQL storage engine
tars源码分析之1
tcp socket 的 recv 如何接收指定长度消息?
Centos8 install mysql 7 unable to start up
NLP-文献阅读总结
leetcode825. Age appropriate friends
How notepad++ counts words