冒泡排序
1 int[] a = {3,6,2,1,5}; 2 for (int i = 0; i < a.Length-1; i++) 3 { 4 for (int j = 0; j < a.Length-i-1; j++) 5 { 6 if (a[j] > a[j + 1]) 7 { 8 int c = a[j]; 9 a[j] = a[j + 1]; 10 a[j + 1] = c; 11 } 12 } 13 } 14 15 foreach (int intItem in a) 16 { 17 Console.WriteLine(intItem+" "); 18 } 19 Console.ReadLine();