文章
17
粉丝
177
获赞
2
访问
118.7k
#include<iostream>
#include<string>
using namespace std;
int date_num(string s){
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int year = stoi(s.substr(0, 4));
int month = stoi(s.substr(4, 2));
int day = stoi(s.substr(6));
int sum = 0;
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) days[1] = 29;
for(int i = 0; i < month - 1;i++){
sum += days[i];
}
sum += day;
return sum;
}
int main(){
string s1, s2;
cin >> s1 >> s2;
if(s1.substr(0, 4) == s2.substr(0, 4)) cout << date_num(s2) - date_num(s1) + 1<< endl;
else{
int sum = 0;
int year_s1 = stoi(s1.substr(0, 4));
int year_s2 = stoi(s2.subs...
登录后发布评论
暂无评论,来抢沙发