瑜_
2018-05-19 21:05
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
switch (month)
{
case 12: day+=30;
case 11: day+=31;
case 10: day+=30;
case 9: day+=31;
case 8: day+=31;
case 7: day+=30;
case 6: day+=31;
case 5: day+=30;
case 4: day+=31;
case 3:
{
if (year%100==0?year%400==0:year%4==0)
day+=29;
else
day+=28;
}
case 2: day+=31;
}
printf ("%d",day);
}
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
int i,moo,sum=0;
for(i=1;i<month;i++)
{switch(i)
{ case 1:moo=31;break;
case 2:moo=28;break;
case 3:moo=31;break;
case 4:moo=30;break;
case 5:moo=31;break;
case 6:moo=30;break;
case 7:moo=31;break;
case 8:moo=31;break;
case 9:moo=30;break;
case 10:moo=31;break;
case 11:moo=30;break;
case 12:moo=31;break;
default:printf("一年中只有12个月哦,喵");break;
}
sum+=moo;
}
sum+=day;
if(year%100!=0&&year%4==0||year%400==0)
sum=sum+1;
printf("%d年%d月%d日是该年的第%d天",year,month,day,sum);
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int today;
if(year%4==0)
{today=day+29; }
else
{today=day+28; }
switch(month)
{
case 8:
today=today+31*4+30*2;
break;
}
printf("%d年%d月%d日是该年的第%d天",year,month,day,today);
return 0;
}
可以的
C语言入门
926210 学习 · 20797 问题
相似问题