当前位置:网站首页>输入年份、月份,确定天数
输入年份、月份,确定天数
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;
}
边栏推荐
- tars源码分析之6
- [FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
- 2022年,或许是未来10年经济最好的一年,2022年你毕业了吗?毕业后是怎么计划的?
- 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
- Mysql 45讲学习笔记(六)全局锁
- Tar source code analysis Part 10
- Selection (022) - what is the output of the following code?
- Bottom problem of figure
- Download address of the official website of national economic industry classification gb/t 4754-2017
- tars源码分析之9
猜你喜欢

Deep profile data leakage prevention scheme

响应式——媒体查询

leetcode825. Age appropriate friends

com. alibaba. nacos. api. exception. NacosException

Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
![[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph](/img/5e/7ce21dd544aacf23b4ceef1ec547fd.png)
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph

Four sets of APIs for queues

what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!

Introduction to spark core components

2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
随机推荐
Latex中的单引号,双引号如何输入?
响应式——媒体查询
Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
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
2022, peut - être la meilleure année économique de la prochaine décennie, avez - vous obtenu votre diplôme en 2022? Comment est - ce prévu après la remise des diplômes?
期末周,我裂开
Tar source code analysis Part 10
Cochez une colonne d'affichage dans une colonne de tableau connue
Design of test cases
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
NLP-文献阅读总结
selenium IDE插件下载安装使用教程
What is the "relative dilemma" in cognitive fallacy?
tars源码分析之10
Bottom problem of figure
tars源码分析之9
电子协会 C语言 1级 34 、分段函数
高薪程序员&面试题精讲系列119之Redis如何实现分布式锁?
Explain in one sentence what social proof is