杭电acm2005题,我的代码调试的答案是正确的啊,为什么在杭电里面提交是wrong answer啊?? 15
#include<stdio.h>intmain(){intsum_day(intm,intd);inty,m,d,sum;while(scanf("%d/%d/%d",...
#include <stdio.h>
int main()
{
int sum_day(int m,int d);
int y,m,d,sum;
while (scanf("%d/%d/%d",&y,&m,&d)!=EOF) {
if (y%4==0&&y%400==0) {
if (m==1) {
sum=d;
printf("%d\n",sum);continue;
}
else if (m==2)
{
sum=31+d;
printf("%d\n",sum);continue;
}
else sum=sum_day(m-2, d)+60; printf("%d\n",sum);continue;
} //闰年
else if (y%4!=0&&y%400!=0)
{
if (m==1) {
sum=d;
printf("%d\n",sum);continue;
}
else if (m==2)
{
sum=31+d;
printf("%d\n",sum);continue;
}
else sum=sum_day(m-2, d)+59;printf("%d\n",sum);continue;
}//平年
}
return 0;
}
int sum_day(int m,int d)
{
int days;
int a[10]={31,30,31,30,31,31,30,31,30,31};
for (m=m-2,days=0; m>=0; m--) {
days+=a[m-2];
}
days=days+d;
return days;
}
求大神解答!!(最好在我的原程序上修改,我知道我的代码很乱。。感激不尽!!) 展开
int main()
{
int sum_day(int m,int d);
int y,m,d,sum;
while (scanf("%d/%d/%d",&y,&m,&d)!=EOF) {
if (y%4==0&&y%400==0) {
if (m==1) {
sum=d;
printf("%d\n",sum);continue;
}
else if (m==2)
{
sum=31+d;
printf("%d\n",sum);continue;
}
else sum=sum_day(m-2, d)+60; printf("%d\n",sum);continue;
} //闰年
else if (y%4!=0&&y%400!=0)
{
if (m==1) {
sum=d;
printf("%d\n",sum);continue;
}
else if (m==2)
{
sum=31+d;
printf("%d\n",sum);continue;
}
else sum=sum_day(m-2, d)+59;printf("%d\n",sum);continue;
}//平年
}
return 0;
}
int sum_day(int m,int d)
{
int days;
int a[10]={31,30,31,30,31,31,30,31,30,31};
for (m=m-2,days=0; m>=0; m--) {
days+=a[m-2];
}
days=days+d;
return days;
}
求大神解答!!(最好在我的原程序上修改,我知道我的代码很乱。。感激不尽!!) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询