随笔分类 - matlab
摘要:写了48行才实现,感觉自己好蠢[],又找不到别的实现方法 function out = find_palindrome(y) a(1)=fix(y/100); z=y-100*a(1); a(2)=fix(z/10); a(3)=mod(z,10); frag=false; e=zeros(1,10
阅读全文
摘要:cody challenge Problem 96. Knight's Tour Checker 代码分享 function tf = knights_tour(a) m=length(a(:,1)); n=length(a(1,:)); c=max(max(a)); tf=true; for b=
阅读全文
摘要:Problem 30. Sort a list of complex numbers based on far they are from the origin. 仅用for循环实现代码 function zSort = complexSort(z) c=1; m=length(z)-1; n=1;
阅读全文
摘要:1.自己的实现代码 function s2 = refcn(s1) s3='aeiouAEIOU'; m=0;n=1; for i=1:length(s1) for j=1:length(s3) s2(n)=s1(i); if s2(n)==s3(j) m=m+1; n=i-m; s2(n+1)='
阅读全文
摘要:1.自己的实现代码 function c = collatz(n) i=1; c(i)=n; if n==1 return; end for i=1:99 if mod(c(i),2) c(i+1)=3*c(i)+1; else c(i+1)=c(i)/2; end if c(i+1)==1 ret
阅读全文
摘要:1.自己写的实现代码 function B = remove_nan_rows(A) a=[]; for i=1:length(A(:,1)) for j=1:length(A(1,:)) if isequal(0,A(i,j)) C(i,j)=A(i,j); else C(i,j)=0./A(i,
阅读全文