#include <iostream>
using namespace std;
const int N = 100010;
int q[N];
void insertion_sort(int q[], int n)
{
for (int i =1 ; i < n ; i ++ )
{
int key = q[i];
while(q[i-1] > key && i - 1 >= 0)
{
q[i]=q[i-1];
i--;
}
q[i]=key;
}
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);
insertion_sort(q, n);
for (int i = 0; i < n; i ++ ) printf("%d ", q[i]);
return 0;
}
头像很危险啊
QAQ leetcode 同款 目前还没事
为什么危险呢?