#6215: 請問一下高手


dark4491 (小強爆走傳說)

學校 : 臺北市立大安高級工業職業學校
編號 : 23049
來源 : [36.228.116.96]
最後登入時間 :
2019-12-09 15:41:17
a263. 日期差幾天 -- 板橋高中練習題 | From: [123.193.67.154] | 發表日期 : 2011-12-31 01:45

我哪裡錯了@@
 WA (line:13)
答案不正確
您的答案為: 294796 正確答案為: 294795
#include<stdio.h>
int countday();
int monthday[]={0,31,59,90,120,151,181,212,243,273,304,334};
int year[2],month[2],day[2];
int main()
{
while(scanf("%d %d %d",&year[0],&month[0],&day[0])!=EOF)
{
scanf("%d %d %d",&year[1],&month[1],&day[1]);
printf("%d\n",countday());
}
return 0;
}
int countday()
{
int i=0,aday=0,bday=0,leap=0,time=0;
aday+=monthday[month[0]-1]+day[0];
bday+=monthday[month[1]-1]+day[1];
do{
if(time!=0)
{
year[0]-=((year[0]-year[1])>0)-((year[0]-year[1])<0);
}
else
{
time++;
}
if((year[0]%4==0 && year[0]%100!=0)||(year[0]%400==0))
{
leap++;
printf("year=%d  leap=%d\n",year[0],leap);
}
aday+=365*(((year[0]-year[1])>0)-((year[0]-year[1])<0));
}while(year[0]!=year[1]);
return ((aday-bday)*(((aday-bday)>0)-((aday-bday)<0))+leap);
}

 
#7008: Re:請問一下高手


bill0129bill (天巧星)

學校 : 國立交通大學
編號 : 17885
來源 : [211.27.251.35]
最後登入時間 :
2024-03-01 15:43:01
a263. 日期差幾天 -- 板橋高中練習題 | From: [163.32.92.90] | 發表日期 : 2012-09-11 19:47

我哪裡錯了@@
 WA (line:13)
答案不正確
您的答案為: 294796 正確答案為: 294795
#include
int countday();
int monthday[]={0,31,59,90,120,151,181,212,243,273,304,334};
int year[2],month[2],day[2];
int main()
{
while(scanf("%d %d %d",&year[0],&month[0],&day[0])!=EOF)
{
scanf("%d %d %d",&year[1],&month[1],&day[1]);
printf("%d\n",countday());
}
return 0;
}
int countday()
{
int i=0,aday=0,bday=0,leap=0,time=0;
aday+=monthday[month[0]-1]+day[0];
bday+=monthday[month[1]-1]+day[1];
do{
if(time!=0)
{
year[0]-=((year[0]-year[1])>0)-((year[0]-year[1])<0);
}
else
{
time++;
}
if((year[0]%4==0 && year[0]%100!=0)||(year[0]%400==0))
{
leap++;
printf("year=%d  leap=%d\n",year[0],leap);
}
aday+=365*(((year[0]-year[1])>0)-((year[0]-year[1])<0));
}while(year[0]!=year[1]);
return ((aday-bday)*(((aday-bday)>0)-((aday-bday)<0))+leap);
}

閏年???

 
ZeroJudge Forum