namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
int[] array = { 43, 69, 11, 72, 28, 21, 56, 80, 48, 94, 32, 8 };
BubbleSort(array);
ShowSord(array);
Console.ReadKey();
}
private static void ShowSord(int[] array)
{
foreach (var num in array)
{
Console.Write($"{num} ");
}
Console.WriteLine();
}
public static void BubbleSort(int[] array)
{
for (int i=0;i<array.Length;i++)
{
for (int j=0;j< array.Length-i-1; j++)
{
if (array [j]> array[j+1])
{
int tempValue = array[j+1];
array[j+1] = array[j];
array[j] = tempValue;
}
}
}
}
}
}
输出: