C# 实现 冒泡排序
2011-09-14 23:37
260 查看
using System; using System.Collections.Generic; using System.Text; using System.Collections; /*** * * 冒泡排序 * * * * **/ namespace TestConsole { class Program { static void Main(string[] args) { int[] array = {32,24 ,21,20,18,3,8,57}; BubbleSort(array); foreach (int index in array) { Console.WriteLine(index + "\t"); } } public static void BubbleSort(int[] array) { int temp = 0; for (int i = 0; i < array.Length - 1; i++) { for (int j = 0; j < array.Length - 1 - i; j++) { if (array[j] > array[j + 1])//如果前一个数比后一个数大,则交换 { temp = array[j + 1]; array[j + 1] = array[j]; array[j] = temp; } } } } } } // 3,8,18,20,21,24,32,57
相关文章推荐
- C#实现冒泡排序之对泛型排序
- C#实现所有经典排序算法(选择排序 冒泡排序 快速排序)
- C#实现冒泡排序与插入排序
- C#实现冒泡排序
- C#实现冒泡排序
- C#实现整数冒泡排序、选择排序
- 排序算法--冒泡排序(Bubble Sort)_C#程序实现
- c#之冒泡排序的三种实现和性能分析
- C#第1次试验(4)设计一个程序,输入10个数存入数组中,然后实现冒泡排序
- C#实现冒泡排序 堆栈 队列
- C#实现冒泡排序 堆栈 队列
- C#实现冒泡排序 堆栈 队列
- (3)C#for循环实现冒泡排序
- C#冒泡排序☞goto实现
- C#实现的3种排序算法--冒泡排序、选择排序、插入排序
- C#实现所有经典排序算法(选择排序 冒泡排序 快速排序)
- C#实现的3种排序算法--冒泡排序、选择排序、插入排序
- C#小练习(设计一个程序,输入10个数存入数组中,然后实现冒泡排序。 )
- C#实现所有经典排序算法(选择排序 冒泡排序 快速排序)
- c#使用“调用函数”的方法实现冒泡排序