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;
}
};
插入排序
最新推荐文章于 2023-09-23 17:47:53 发布