2个回答
展开全部
int i, num, year, month, day,d[12];
d[0] = 31;
d[1] = 28;
d[2] = 31;
d[3] = 30;
d[4] = 31;
d[5] = 30;
d[6] = 31;
d[7] = 31;
d[8] = 30;
d[9] = 31;
d[10] = 30;
d[11] = 31;
while (true)
{
num = 0;
scanf("%d",&year);
scanf("%d",&month);
scanf("%d",&day);
if (year % 4 == 0) d[1] = 29;
for (i = 0; i < month - 1; i++) num += d[i];
num += day;
printf("%d",num);
}
一稿多投,帮忙赚点分吧,谢谢
d[0] = 31;
d[1] = 28;
d[2] = 31;
d[3] = 30;
d[4] = 31;
d[5] = 30;
d[6] = 31;
d[7] = 31;
d[8] = 30;
d[9] = 31;
d[10] = 30;
d[11] = 31;
while (true)
{
num = 0;
scanf("%d",&year);
scanf("%d",&month);
scanf("%d",&day);
if (year % 4 == 0) d[1] = 29;
for (i = 0; i < month - 1; i++) num += d[i];
num += day;
printf("%d",num);
}
一稿多投,帮忙赚点分吧,谢谢
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
int main()
{
int year,month,day,sum,leap;
printf("Please enter year,month,day (just like:2009,9,9)\n");
scanf("%d,%d,%d",&year,&month,&day);
switch(month)
{case 1 : sum=0;
break;
case 2 : sum=31;
break;
case 3 : sum=59;
break;
case 4 : sum=90;
break;
case 5 : sum=120;
break;
case 6 : sum=151;
break;
case 7 : sum=181;
break;
case 8 : sum=212;
break;
case 9 : sum=243;
break;
case 10 : sum=273;
break;
case 11 : sum=304;
break;
case 12 : sum=334;
break;
default : printf("Enter wrong!Please enter right date.\n");
break;
}
sum=sum+day;
if (year%4==0&&year%100!=0||year%400==0)
leap=1;
else
leap=0;
if(leap==1&&month>2)
sum=sum+1;
printf("It is the %dth day.",sum);
return 0;
}
int main()
{
int year,month,day,sum,leap;
printf("Please enter year,month,day (just like:2009,9,9)\n");
scanf("%d,%d,%d",&year,&month,&day);
switch(month)
{case 1 : sum=0;
break;
case 2 : sum=31;
break;
case 3 : sum=59;
break;
case 4 : sum=90;
break;
case 5 : sum=120;
break;
case 6 : sum=151;
break;
case 7 : sum=181;
break;
case 8 : sum=212;
break;
case 9 : sum=243;
break;
case 10 : sum=273;
break;
case 11 : sum=304;
break;
case 12 : sum=334;
break;
default : printf("Enter wrong!Please enter right date.\n");
break;
}
sum=sum+day;
if (year%4==0&&year%100!=0||year%400==0)
leap=1;
else
leap=0;
if(leap==1&&month>2)
sum=sum+1;
printf("It is the %dth day.",sum);
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询