#37953: WA(line2) 幫幫我吧大佬們！

#### mia2277 (雲貓)

School : 忠信學校
ID : 247272
2024-08-04 18:19:21
a263. 日期差幾天 -- | From: [61.220.127.183] | Post Date : 2023-10-20 19:37

#include <bits/stdc++.h>
using namespace std;

int main()
{
int y1,m1,d1,y2,m2,d2,t_s1,t_s2,t_s3,a;
cin>>y1>>m1>>d1;
cin>>y2>>m2>>d2;
/***************year1******************/
t_s1 = (y1 - 1)*365;
t_s1 += (y1 - 1)/4 - (y1 - 1)/100 +(y1 - 1)/400;
/***************month1******************/
if(7 > (m1 - 1) && (m1 - 1) >= 2 ){
t_s1 += 59+(((m1 - 1)/2- 1)*61)+(31*((m1 - 1)%2));
}else if(m1 - 1>=7){
t_s1+=212+((m1 - 8)/2)*61+31*((m1 - 8)%2);
}else if(m1 - 1<2){
t_s1+=31;
}
if((y1%4 == 0 && (m2- 1)>=2 && y1%100!=0)||y1%400==0){
t_s1+=1;
}
///////////////day1///////////////
t_s1 += d1;
/***************year2******************/
t_s2 = (y2 - 1)*365;
t_s2 += (y2 - 1)/4 - (y2 - 1)/100 +(y2 - 1)/400;

/***************month2******************/
if(7> m2- 1 && m2- 1 >= 2 ){
t_s2+=((m2- 1)/2- 1)*61+31*((m2- 1)%2)+59;
}else if((m2-1)>=7){
t_s2+= 212+((m2 - 8)/2)*61+31*((m2- 8)%2);
}else if(m2- 1 < 2){
t_s2+=31;
}
if((y2%4 == 0 && (m2- 1)>=2 && y2%100 != 0)||y2%400==0){
t_s2+=1;
}
///////////////day2//////////////
t_s2 += d2;

t_s3=t_s1-t_s2;

if(t_s3<1){
t_s3= -1*t_s3;
}
cout<<t_s3<<"\n";

return 0;
}

#37955: Re: WA(line2) 幫幫我吧大佬們！

#### asnewchien@gmail.com (david)

School : No School
ID : 68108
2024-07-27 21:17:52
a263. 日期差幾天 -- | From: [122.117.95.179] | Post Date : 2023-10-20 20:13

#include
using namespace std;

int main()
{
int y1,m1,d1,y2,m2,d2,t_s1,t_s2,t_s3,a;
cin>>y1>>m1>>d1;
cin>>y2>>m2>>d2;
/***************year1******************/
有多筆測資

ZeroJudge Forum