![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
static void BubbleSort(int[] array)
{
for (int i = 0; i < array.Length; i++)
{
for (int j = i + 1; j < array.Length; j++)
{
if (array[j] > array[i])
{
int tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
foreach (int a in array)
{
Console.Write(a + " ");
}
Console.Write(Environment.NewLine);
}
}
static void Main(string[] args)
{
int[] a = new int[] { 6,2,5,3,1,4,7 };
BubbleSort(a);
}
{
for (int i = 0; i < array.Length; i++)
{
for (int j = i + 1; j < array.Length; j++)
{
if (array[j] > array[i])
{
int tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
foreach (int a in array)
{
Console.Write(a + " ");
}
Console.Write(Environment.NewLine);
}
}
static void Main(string[] args)
{
int[] a = new int[] { 6,2,5,3,1,4,7 };
BubbleSort(a);
}