插入排序

来源:互联网 发布:韩国电影推荐 知乎 编辑:程序博客网 时间:2024/06/06 10:45
class InsertionSort {public:    int* insertionSort(int* A, int n) {        // write code here        for(int i=1;i<n;i++)            {            for(int j=i;j>0;j--)                {                if(A[j]<A[j-1])                    {                    swap(A[j],A[j-1]);                }            }        }        return A;    }};
0 0
原创粉丝点击