Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.25 KB | None | 0 0
  1. function A = selection(A)
  2.     n = length(A);
  3.     for i = 1:n
  4.         index = i;
  5.         for j = i+1:n
  6.             if A(j) < A(index)
  7.                 index = j;
  8.             endif
  9.         endfor
  10.         if index != i
  11.             temp = A(index);
  12.             A(index) = A(i);
  13.             A(i) = temp;
  14.         endif
  15.     endfor
  16. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement