![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
static void InsertSort(int[] array)
{
for (int i = 1; i < array.Length; i++)
{
if (array[i] < array[i - 1])
{
int tem=array[i];
int j = 0;
for (j = i - 1; j >= 0 && tem < array[j]; j--)
{
array[j + 1] = array[j];
}
array[j + 1] = tem;
}
}
}
static void Main(string[] args)
{
int[] a = new int[] { 6,2, 5, 3, 1, 4 };
InsertSort(a);
}
{
for (int i = 1; i < array.Length; i++)
{
if (array[i] < array[i - 1])
{
int tem=array[i];
int j = 0;
for (j = i - 1; j >= 0 && tem < array[j]; j--)
{
array[j + 1] = array[j];
}
array[j + 1] = tem;
}
}
}
static void Main(string[] args)
{
int[] a = new int[] { 6,2, 5, 3, 1, 4 };
InsertSort(a);
}