冒泡排序
回顾复习:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 static void Main(string[] args) 2 { 3 int[] arr = { 2, 3, 1, 5,8, 4 }; 4 5 for (int i = 0; i < arr.Length; i++) 6 { 7 for (int j = 0; j < arr.Length-1-i; j++) 8 { 9 if (arr[j] > arr[j+1]) 10 { 11 int temp = arr[j]; 12 arr[j] = arr[j+1]; 13 arr[j+1] = temp; 14 } 15 } 16 } 17 18 arr.ToList().ForEach(a => Console.Write(a)); 19 20 Console.ReadLine(); 21 }