代码较少的题解
2023-10-08 19:10:15
发布于:浙江
8阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main()
{
int year,mouth;
cin>>year>>mouth;
int _mouth[13]={31,28,31,30,31,30,31,31,30,31,30,31};
if(year%1000){
if(year%4000){
_mouth[1];
}
}
else {
if(year%4==0){
_mouth[1];
}
}
cout<<_mouth[mouth-1];
return 0;
}
全部评论 1
#include <iostream>
using namespace std;
bool isLeapYear(int year) {
return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
int main() {
int year, month;
cin >> year >> month;
if (month == 2) {
cout << (isLeapYear(year) ? 29 : 28) << endl;
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
cout << 30 << endl;
} else {
cout << 31 << endl;
}
return 0;
}2024-08-15 来自 浙江
0
有帮助,赞一个