protected int[] bubbleUp(int[] Array)//冒泡排序
{
for (int i = 0; i < Array.Length-1; i++)//要冒泡次数
{
for (int j = 0; j < Array.Length-1-i; j++)//每次冒泡具体比较过程
{
if (Array[j] < Array[j + 1])
{
int temp = Array[j + 1];
Array[j + 1] = Array[j];
Array[j] = temp;
}
}
}
return Array;
}
public int[] SelectionSorter(int[] list)//选择排序
{
int min;
for (int i = 0; i < list.Length - 1; i++)
{
min = i;
for (int j = i + 1; j < list.Length; j++ )
{
if (list[j] < list[min])
min = j;
}
int temp = list[min];
list[min] = list;
list = temp;
}
return list;
}
public int[] InsertionSorter(int[] list)// 插入排序
{
for (int i = 1; i < list.Length; i++)
{
int temp = list;
int j = i;
while ((j > 0) && (list[j - 1] > temp))
{
list[j] = list[j - 1];
--j;
}
list[j] = temp;
}
return list;
}
public int[] ShellSorter(int[] list)//希尔排序
{
int inc;
for (inc = 1; inc <= list.Length / 9; inc = 3 * inc + 1) ;
for (; inc > 0; inc /= 3)
{
for (int i = inc + 1; i <= list.Length; i += inc)
{
int t = list[i - 1];
int j = i;
while ((j > inc) && (list[j - inc - 1] > t))
{
list[j - 1] = list[j - inc - 1];
j -= inc;
}
list[j - 1] = t;
}
}
return list;
}