1.冒泡排序
请通过冒泡排序法对整数数组{ 1, 3, 5, 7, 90, 2, 4, 6, 8, 10 }实现升序排序
int[] num = { 1, 3, 5, 7, 90, 2, 4, 6, 8, 10 }; BubbleSort(num); Console.ReadLine();
private static void BubbleSort(int[] num) { for (int i = 0; i < num.Length - 1; i++) { for (int j = num.Length - 1; j > i; j--) { if(num[j] < num[j - 1]) { int tmp = num[j]; num[j] = num[j - 1]; num[j - 1] = tmp; } } } for (int n = 0; n < num.Length; n++) { Console.WriteLine(num[n]); } }