求大神将下面的c语言改成能在Matlab上运行的!急!急!#include intdays[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}};char s[8][10] ={"Monday","Tuesday","Wednesday","Thursday","F
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 12:13:00
求大神将下面的c语言改成能在Matlab上运行的!急!急!#include intdays[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}};char s[8][10] ={"Monday","Tuesday","Wednesday","Thursday","F
求大神将下面的c语言改成能在Matlab上运行的!急!急!
#include
intdays[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}
};
char s[8][10] ={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
bool is_leap(int year)
{
return (year%4==0 && year%100) || (year % 400 == 0);
}
int DateToInt(int year,int mon,int day)
{
int ans=0,t=is_leap(year) ? 1 : 0 ;
for(int i=1 ; i
求大神将下面的c语言改成能在Matlab上运行的!急!急!#include intdays[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}};char s[8][10] ={"Monday","Tuesday","Wednesday","Thursday","F
程序如下,已经做子函数处理,所以请放在一个m文件中运行:
function [] = myhelp()
clear;
clc;
week = ['Monday ';'Tuesday ';'Wednesday';'Thursday ';'Friday ';'Saturday ';'Sunday '];
week = cellstr(week);
%printf('Input the date (eg 2013 10 21 , -1 ends the input):\n');
year = input('Input year:');
mon = input('Input month:');
day = input('Input day:');
myday = DateToInt(year,mon,day);
cxd = mod(myday+6,7);
disp('six days later is:')
disp(week(cxd))
function myday = DateToInt(year,mon,day)
days =[31,28,31,30,31,30,31,31,30,31,30,31;31,29,31,30,31,30,31,31,30,31,30,31];
myday = 0;
t = is_leap(year);
for ii = 1:year-1
myday = myday + is_leap(ii)*366+(1-is_leap(ii))*365;
for jj = 1:mon-1
myday = myday + days(t+1,jj);
end
end
myday = myday + day;
function isleap = is_leap(year)
isleap = (mod(year,4)==0 && mod(year,100)~=0) || (mod(year,400)==0) ;
实例:
Input year:2013
Input month:10
Input day:22
six days later is:
'Monday'
有问题可以追问
copyright (c) cxd1301