文章
4
粉丝
0
获赞
6
访问
61
#include<bits/stdc++.h>
using namespace std;
int Isleap(int year){
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
return 1; // 是闰年
}
return 0; // 不是闰年
}
int Totalday(int year,int month,int day){//新手笨方法,算从元年到输入日期的总天数再相减
int total=0;
for(int i=0;i<year;i++){
if(Isleap(i))
total+=366;
else
total+=365;
}
int f[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for(int i=0;i<month;i++){
total+=f[i];
if(i==2&&Isleap(year)){
total+=1;
}
}
total+=day;
return total;
}
int main(){
long long date1, date2;
int y1, m1, d1, y2, m2, d2;
int days1, days2, days;
while (scanf("%lld%lld", &date1, &date2) == 2) {
// 拆解第一个日期
y1 = date1 / 10000; // 取前4位(年)
m1 = (date1 / 100) % 100; // 取中间2位(月)
d1 = date1 % 100; // 取最后2位(日)
// 拆解第二个日期
y2 = date2 / 10000;
m2 = (date...
登录后发布评论
暂无评论,来抢沙发