文章
33
粉丝
0
获赞
133
访问
3.6k
#include<bits/stdc++.h>
using namespace std;
int NoLeap[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//365
int Leap[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//366
bool isLeapyear(int x){
if((x%4==0 && x%100!=0) || x%400==0) return true;
else return false;
}
void print_NoLeap(string s1,string s2){//其实两个函数逻辑0个区别,只是写的时候复制粘贴很方便.只用改个数组名
//处理的逻辑还是Year-Month-Day来打印的
int days = stoi(s2);
int i = 1;
while(days>0){
days = days - NoLeap[i];
i++;
}
if(i>1) i--;
int d = days + NoLeap[i];
cout<<s1<<"-";
if(i>=10){
cout<<i<<"-";
if(d>=10) cout<<d<<endl;
else cout<<"0"<<d<<endl;
}
else{
cout<<"0"<<i<<"-";
if(d>=10) cout<<d<<endl;
else cout<<"0"<<d<<endl;
}
}
void print_Leap(string s1,string s2){
int days = stoi(s2);
int i = 1;
...
登录后发布评论
暂无评论,来抢沙发