伪代码
BUBBLESORT(A)
for i = 1 to A.length - 1
for j = A.length to i + 1
if A[j] < A[j - 1]
exchange A[j] with A[j - 1]
c#代码
static void BubbleSort(int[] array)
{
for(int i = 0; i < array.Length - 1; i++)
{
for(int j = array.Length - 1; j > i; j--)
{
if(array[j] < array[j - 1])
{
int temp = array[j];
array[j] = array[j - 1];
array[j - 1] = temp;
}
}
}
}