当前位置:网站首页>输入年份、月份,确定天数
输入年份、月份,确定天数
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;
}
边栏推荐
- Selenium driver ie common problem solving message: currently focused window has been closed
- Responsive mobile web test questions
- Mysql 45讲学习笔记(十四)count(*)
- Mysql 45讲学习笔记(六)全局锁
- How notepad++ counts words
- MySQL 45 lecture learning notes (12) MySQL will "shake" for a while
- Tar source code analysis Part 3
- What is industrial computer encryption and how to do it
- [thread pool]
- Fundamentals of SQL database operation
猜你喜欢
[backpack DP] backpack problem
[thread pool]
uniapp小程序分包
What is industrial computer encryption and how to do it
Mobile adaptation: vw/vh
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Splicing plain text into JSON strings - easy language method
Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture
Google Chrome Portable Google Chrome browser portable version official website download method
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
随机推荐
校园网络问题
CORS is not intended to protect API endpoints - nikofischer
[thread pool]
The final week, I split
How notepad++ counts words
What is industrial computer encryption and how to do it
Tar source code analysis Part 2
MySQL 45 lecture learning notes (XIV) count (*)
在已經知道錶格列勾選一個顯示一列
图的底部问题
MySQL 45 lecture learning notes (VI) global lock
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
tars源码分析之8
tars源码分析之2
Google Chrome Portable Google Chrome browser portable version official website download method
Tar source code analysis 8
Mysql 45讲学习笔记(七)行锁
tcp socket 的 recv 如何接收指定长度消息?
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
tars源码分析之6