static void Main(string[] args)
{
//冒泡法
int[] myArray = new int[10] { 0,2,1, 8, 3, 5, 6, 7, 4, 9 };
int temp = 0;
for (int i = 1; i < myArray.Length; i++)
{
for (int j = 0; j < myArray.Length - i; j++)
{
// 如果 myArray[i] > myArray[i+1] ,则 myArray[i] 上浮一位
if (myArray[j] > myArray[j + 1])
{
temp = myArray[j];
myArray[j] = myArray[j + 1];
myArray[j + 1] = temp;
}
}
}
foreach (int x in myArray)
{
Console.WriteLine(x);
}
Console.ReadKey();
}