文章
55
粉丝
100
获赞
12
访问
31.1k
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
//有两个日期,求两个日期之间的天数,如果两个日期是连续的我们规定他们之间的天数为两天
int main(){
int arr[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int d1,d2;
while(cin>>d1>>d2){
int year1 = d1 / 10000;
int month1 = d1%10000/100;
int day1 = d1%100;
// cout<<year1 <<" " << month1<<" "<<day1;
int year2 = d2 / 10000;
int month2 = d2%10000/100;
int day2 = d2%100;
int n = 1;
for(int i = 0; !(year1==year2&&month1==month2&&day1==day2);i++){
bool isLeap = year1%400==0 || year1%100!=0&&year1%4==0;
if(isLeap){
arr[2] = 29;
}
++day1;
++n;
if(day1>arr[month1]){
day1=1;
month...
登录后发布评论
暂无评论,来抢沙发