![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
求助 Matlab编程题
编写程序计算2007和2008年中的任意一天是星期几并计算出是一年中的第几天。输入格式为:Month/day/year-xx/xx/xxxx。程序输出结果一下列方式显示:...
编写程序计算2007和2008年中的任意一天是星期几并计算出是一年中的第几天。输入格式为:Month/day/year-xx/xx/xxxx。程序输出结果一下列方式显示:the date 5/31/2000 is the 152 day of the year and falls oa a wednesday.
展开
展开全部
clc;
clear all;
str_week = {'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'};
str_date = input('Please input a date(mm/dd/yyyy):','s');
str_yearFirst = ['01/01',str_date((length(str_date)-4):(length(str_date)))];
str_datenum = int2str(datenum(str_date,'mm/dd/yyyy')-datenum(str_yearFirst,'mm/dd/yyyy')+1);
disp(['the date ',str_date,' is the ',str_datenum,' day of the year and falls on a ',str_week{weekday(str_date,'mm/dd/yyyy')},'.']);
% Please input a date(mm/dd/yyyy):5/31/2000
% the date 5/31/2000 is the 152 day of the year and falls on a Wednesday.
clear all;
str_week = {'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'};
str_date = input('Please input a date(mm/dd/yyyy):','s');
str_yearFirst = ['01/01',str_date((length(str_date)-4):(length(str_date)))];
str_datenum = int2str(datenum(str_date,'mm/dd/yyyy')-datenum(str_yearFirst,'mm/dd/yyyy')+1);
disp(['the date ',str_date,' is the ',str_datenum,' day of the year and falls on a ',str_week{weekday(str_date,'mm/dd/yyyy')},'.']);
% Please input a date(mm/dd/yyyy):5/31/2000
% the date 5/31/2000 is the 152 day of the year and falls on a Wednesday.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询