已知1800年1月1日星期三,计算每月第一天星期几?要C语言的表达式,初学者,不要太复杂,谢谢 5
2个回答
展开全部
如果只求1800年内……
int mon[13],i=1,week[13];
switch(i)
{
case 1: mon[i]=0;week[i]=3;i++;
case 2: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 3: mon[i]+=28;week[i]=(mon[i]+3)/7+1;i++;//1800不是闰年
case 4: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 5: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
case 6: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 7: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
case 8: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 9: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 10: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
case 11: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 12: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
}
for(i=1;i<13;i++)
{
printf("%d月第一天为星期%d\n",i,week[i])
}
int mon[13],i=1,week[13];
switch(i)
{
case 1: mon[i]=0;week[i]=3;i++;
case 2: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 3: mon[i]+=28;week[i]=(mon[i]+3)/7+1;i++;//1800不是闰年
case 4: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 5: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
case 6: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 7: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
case 8: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 9: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 10: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
case 11: mon[i]+=31;week[i]=(mon[i]+3)/7+1;i++;
case 12: mon[i]+=30;week[i]=(mon[i]+3)/7+1;i++;
}
for(i=1;i<13;i++)
{
printf("%d月第一天为星期%d\n",i,week[i])
}
更多追问追答
追问
也要求其他年份,谢谢
追答
是不是让输入一个年份然后求没有第一天为星期几?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询