ZKX's LAB

程序设计:输入某年某月某日判断这天是这一年的第多少天的流程图,以及报告表 matlab输入某年某月某日

2021-04-23知识2

刚刚开始学习MATLAB,下面是我编的程序,求某年某月某日是星期几,不知道哪里错了,求帮助,越详细越好 function xingqi=myfun(year,month,day)clc2000年1月1日星期六dy=2*(year>;=2000)-1;y=2000:dy:year;p=mod(y,400)=0|mod(y,100)~=0&mod(y,4)=0;yue=[31 28+p(end)31 30 31 30 31 31 30 31 30 31];xingqi=mod(dy*sum(p((1:end-1)+(dy)))+365*(year-2000)+sum(yue(1:month-1))+day+5,7);xingqi=xingqi+(xingqi=0)*7;end

输入某年某月某日,判断这一天是这一年的第几天? 程序分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且输入月份大于3时需考虑多加一天。includeint main(){int day,month,year,sum,leap;printf(\"Please enter year-month-day:\\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(\"Month error\");break;}sum=sum+day;再加上某天的天数*/if((0=year%4&0。year%100)|0=year%400)/*判断是不是闰年*/leap=1;elseleap=0;if(1=leap&month>;2)/*如果是闰年且月份大于2,总天数应该加一天*/sum+;printf(\"It is the%dth day.\\n\",sum);}

编写程序计算某年某月的天数.输入年份year和月份month,输出该月份的天数 include int main(){ int year,month;int a=0;printf(\"输入任意符合范围(1月~12月)的月份和(1900年~9999年)年份,且两个值之间空格分隔。\\n\");scanf(\"%d%d\",&year,&。

#matlab输入某年某月某日

随机阅读

qrcode
访问手机版