文章
43
粉丝
0
获赞
56
访问
9.1k
#include<bits/stdc++.h>
using namespace std;
struct data{
int y;
int m;
int d;
};
// 判断月份和日是否合理
bool isTrue(data c){
if(c.m>12||c.m<1){
return false;
}else{
if(c.m==1||c.m==3||c.m==5||c.m==7||c.m==8||c.m==10||c.m==12){
if(c.d>=1&&c.d<=31){
return true;
}else{
return false;
}
}else if(c.m==2){
// 闰年
if((c.y%4==0&&c.y%100!=0)||c.y%400==0){
if(c.d>=1&&c.d<=29){
return true;
}else{
return false;
}
}else{
if(c.d>=1&&c.d<=28){
return true;
}else{
return false;
}
}
}else{
if(c.d>=1&&c.d<=30){
return true;
}else{
return false;
}
}
}
}
// 计算天数
int cSum(data c){
int sum=0;
if(c.m==1){
sum=c.d;
}else if(c.m==2){
sum=31+c.d;
}else if(c.m==3){
sum=31+28+c.d;//这里2月统一按28天来计算,最后再判断闰年,来调整sum的值
}else if(c.m==4){
sum=31+28+31+c.d;
}else if(c.m=...
登录后发布评论
暂无评论,来抢沙发