Check the problem statement here:
https://www.mathworks.com/matlabcentr...
CODE:
clc
clear all
close all
x=input('Enter the array');
z=input('Enter the number:');
y=[];
l=length(x);
for i=1:length(x) c=x(i)-z; c=abs(c); y=[y c];
end
zi=fliplr(sort(y));
o=[];
for i=1:length(zi) c=zi(i); for j=1:length(x) if(abs(x(j)-z)==c) o=[o x(j)]; end end
end
disp(o);
Code as function:
function o = targetSort(x,z)
y=[];
l=length(x);
for i=1:length(x) c=x(i)-z; c=abs(c); y=[y c];
end
zi=fliplr(sort(y));
o=[];
for i=1:length(zi) c=zi(i); for j=1:length(x) if(abs(x(j)-z)==c) o=[o x(j)]; end end
end
end
https://www.mathworks.com/matlabcentr...
CODE:
clc
clear all
close all
x=input('Enter the array');
z=input('Enter the number:');
y=[];
l=length(x);
for i=1:length(x) c=x(i)-z; c=abs(c); y=[y c];
end
zi=fliplr(sort(y));
o=[];
for i=1:length(zi) c=zi(i); for j=1:length(x) if(abs(x(j)-z)==c) o=[o x(j)]; end end
end
disp(o);
Code as function:
function o = targetSort(x,z)
y=[];
l=length(x);
for i=1:length(x) c=x(i)-z; c=abs(c); y=[y c];
end
zi=fliplr(sort(y));
o=[];
for i=1:length(zi) c=zi(i); for j=1:length(x) if(abs(x(j)-z)==c) o=[o x(j)]; end end
end
end
TARGET SORTING video editing software free | |
1 Likes | 1 Dislikes |
18 views views | 1.03K followers |
Science & Technology | Upload TimePublished on 9 Aug 2019 |
Không có nhận xét nào:
Đăng nhận xét