当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

云Redis 有什么用? 云redis怎么用?

Cervical vertebra, beriberi

电脑通过Putty远程连接树莓派

关于IDEA如何设置快捷键集

the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
![[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA](/img/71/1d6179921ae84b1ba61ed094e592ff.png)
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA

Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction

About how idea sets up shortcut key sets

Responsive - media query

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
随机推荐
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
测试用例的设计
2022年6月小结
MySQL 45 lecture learning notes (XIV) count (*)
Electronic Association C language level 1 35, bank interest
Check and display one column in the known table column
Analysis of tars source code 1
Mysql 45讲学习笔记(七)行锁
The important role of host reinforcement concept in medical industry
MySQL 45 learning notes (XI) how to index string fields
js 常用时间处理函数
NLP literature reading summary
Crawler (III) crawling house prices in Tianjin
Tar source code analysis Part 10
tars源码分析之6
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
tars源码分析之5
【FPGA教程案例8】基于verilog的分频器设计与实现
Tar source code analysis 8
[MySQL transaction]