杭电 ACM 2005 WRONG ANSWER
#include<cstdio>intrun(intx){if((x%4==0&&x%100!=0)||(x%400)==0)return1;elsereturn0;}i...
#include<cstdio>
int run(int x)
{
if((x%4==0&&x%100!=0)||(x%400)==0)return 1;
else return 0;
}
int main()
{
int m[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int days,i,sig,year,month,day;
while(scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
days=0;
sig=run(year);
for(i=1;i<month;i++)
days+=m[i];
days+=day;
if(sig==1&&month>2)days++;
printf("%d\n",days);
}
return 0;
} 展开
int run(int x)
{
if((x%4==0&&x%100!=0)||(x%400)==0)return 1;
else return 0;
}
int main()
{
int m[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int days,i,sig,year,month,day;
while(scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
days=0;
sig=run(year);
for(i=1;i<month;i++)
days+=m[i];
days+=day;
if(sig==1&&month>2)days++;
printf("%d\n",days);
}
return 0;
} 展开
2个回答
展开全部
//******************************************************************************
// 杭电2005 第几天? 代码已AC
//******************************************************************************
#include<stdio.h> //标准C 头文件 ,AC时 Language选 C
int run(int x)
{
if ((x%4==0&&x%100!=0)||(x%400)==0)return 1;
else return 0;
}
int main()
{
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//依据后面代码,应该在前面添加一个 0
int days,i,sig,year,month,day;
while (scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
days=0;
sig=run(year);
for (i=1;i<month;i++) //***** i 是从1开始计数的 ,所以上面数组前面再加一个 0****
days+=m[i];
days+=day;
if (sig==1&&month>2)days++;
printf("%d\n",days);
}
return 0;
}
//******************************************************************************
// 祝学习进步,更上一层楼 *(^-^)*
//******************************************************************************
// 杭电2005 第几天? 代码已AC
//******************************************************************************
#include<stdio.h> //标准C 头文件 ,AC时 Language选 C
int run(int x)
{
if ((x%4==0&&x%100!=0)||(x%400)==0)return 1;
else return 0;
}
int main()
{
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//依据后面代码,应该在前面添加一个 0
int days,i,sig,year,month,day;
while (scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
days=0;
sig=run(year);
for (i=1;i<month;i++) //***** i 是从1开始计数的 ,所以上面数组前面再加一个 0****
days+=m[i];
days+=day;
if (sig==1&&month>2)days++;
printf("%d\n",days);
}
return 0;
}
//******************************************************************************
// 祝学习进步,更上一层楼 *(^-^)*
//******************************************************************************
展开全部
#include<cstdio>
int run(int x)
{
if((x%4==0&&x%100!=0)||(x%400)==0)return 1;
else return 0;
}
int main()
{
int m[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int days,i,sig,year,month,day;
while(scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
days=0;
sig=run(year);
for(i=1;i<month;i++)
days+=m[i-1];//这里应该是m[i-1].你再试一下。
days+=day;
if(sig==1&&month>2)days++;
printf("%d\n",days);
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询