当前位置:网站首页>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;
}
边栏推荐
- How to input single quotation marks and double quotation marks in latex?
- Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
- Cochez une colonne d'affichage dans une colonne de tableau connue
- 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?
- Responsive mobile web test questions
- Summary of June 2022
- 云Redis 有什么用? 云redis怎么用?
- What is a spotlight effect?
- 【FPGA教程案例7】基于verilog的计数器设计与实现
- Explain in one sentence what social proof is
猜你喜欢
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
What is industrial computer encryption and how to do it
"Sword finger offer" 2nd Edition - force button brush question
selenium IDE插件下载安装使用教程
MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
leetcode825. 适龄的朋友
响应式移动Web测试题
How to share the source code anti disclosure scheme
About how idea sets up shortcut key sets
随机推荐
Label management of kubernetes cluster
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
Boast about Devops
tars源码分析之9
Crawler (III) crawling house prices in Tianjin
selenium IDE插件下载安装使用教程
电子协会 C语言 1级 35 、银行利息
Responsive mobile web test questions
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
What is the sheji principle?
ABCD four sequential execution methods, extended application
Four sets of APIs for queues
Deep profile data leakage prevention scheme
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
Analysis of tars source code 1
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
Mysql 45讲学习笔记(十四)count(*)
Cervical vertebra, beriberi
Master-slave replication principle of MySQL database