#include <iostream>
using namespace std;
int sort_insert(int *A)
{
for (int i = 1; i <= 5; ++i)
{
int key = A[i];
int j = i - 1;
while (j>=0 && A[j]>key)
{
A[j+1] = A[j];
--j;
}
A[j+1] = key;
}
return 0;
}
int main()
{
int A[6] = {4, 3, 4, 5, 6, 7};
sort_insert(A);
for (int i = 0; i <= 5; ++i)
{
cout << A[i];
}
return 0;
}
插入排序
最新推荐文章于 2023-09-23 17:47:53 发布