function a_ed = arraysort(a)
%冒泡排序法
for i =1:length(a)-1
    %进行多少次比较
    for j=1+i:length(a)
        %每次求出最大的数,放在最后
        if(a(j)<a(i))
            tem = a(i);
            a(i) = a(j);
            a(j) = tem;
        end
    end
    a_ed = a;
end
clc;
clear;
a = [2 4 4 6 14 0 2 8 4 1 9 4]
b = arraysort(a)

版权声明:本文为KongkOngL原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/KongkOngL/p/4074437.html