Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Five-weekends/MATLAB/five-weekends.m
Normal file
25
Task/Five-weekends/MATLAB/five-weekends.m
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
longmonth = [1 3 5 7 8 10 12];
|
||||
|
||||
i = 1;
|
||||
|
||||
for y = 1900:2100
|
||||
for m = 1:numel(longmonth)
|
||||
[num,name] = weekday(datenum(y,longmonth(m),1));
|
||||
if num == 6
|
||||
x(i,:) = datestr(datenum(y,longmonth(m),1),'mmm yyyy'); %#ok<SAGROW>
|
||||
i = i+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fprintf('There are %i months with 5 weekends between 1900 and 2100.\n',length(x))
|
||||
|
||||
fprintf('\n The first 5 months are:\n')
|
||||
for j = 1:5
|
||||
fprintf('\t %s \n',x(j,:))
|
||||
end
|
||||
|
||||
fprintf('\n The final 5 months are:\n')
|
||||
for j = length(x)-4:length(x)
|
||||
fprintf('\t %s \n',x(j,:))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue