#include <iostream>
using namespace std;
const int N = 10;
int data[] ={6,1,2,7,9,3,4,5,10,8};
void directInsertSort(int* data,int n);
void printArray(int* data, int n);
int main()
{
directInsertSort(data,N);
printArray(data,N);
return 0;
}
void directInsertSort(int* data,int n)
{
int temp = 0;
int i,j,k;
for(i=1;i<n;++i)
{
temp = data[i];
for(j=i-1;j>=0;--j)
{
if(temp>=data[j]) break;
}
for(k=i-1;k>=j+1;--k)
{
data[k+1] = data[k];
}
data[j+1] = temp;
}
}
void printArray(int* data, int n)
{
for(int i=0;i<n;++i)
{
cout<<data[i]<<" ";
}
cout<<endl;
}