编辑代码

#include <bits/stdc++.h>
using namespace std;

void InsertSort(int a[],int n){
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j>=0;j--){
            if (a[j]>a[j-1]) swap(a[j],a[j-1]);
            else break;
        }
    }
}

void show_elem(int a[],int n){
    for(int i=0;i<n;i++)
    cout<<a[i]<<' ';
    cout<<endl;
}



int main()
{
    int a[20]={-65536,53,17,78,9,45,65,87,32};
    int n=9;

    InsertSort(a,n);
    show_elem(a,n) ;

}