冒泡排序
来源:互联网 发布:java类声明 编辑:程序博客网 时间:2024/06/04 00:41
好像跑起来没啥问题~~~~~
class Program { static void Main(string[] args) { int[] beforeSort = new int[] { 5, 3, 8, 6, 9, 1, 4, 2, 7 }; Console.Write("排序前:"); for (int i = 0; i < beforeSort.Length; i++) { Console.Write(beforeSort[i].ToString()); } Console.Write("\r\n排序后:"); int[] afterSort = BubbleSort(beforeSort); for (int j = 0; j < afterSort.Length; j++) { Console.Write(afterSort[j].ToString()); } Console.ReadKey(); } static int[] BubbleSort(int[] BeforeSort) { int[] sortArr = (int[])BeforeSort.Clone(); for (int i = 0; i < sortArr.Length; i++) { for (int j = 0; j < sortArr.Length - 1; j++) { int temp = 0; if (sortArr[j] > sortArr[j + 1]) { temp = sortArr[j]; sortArr[j] = sortArr[j + 1]; sortArr[j + 1] = temp; } } } return sortArr; }
0 0
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- MD5 加密方法
- basket nike tn pas cher or with a towel
- Cocos2d-x 3.0心得(05)-音效管理
- Ray Ban France the captain closed the door after five people blocking up the plane took off more th
- 数据结构:点对之间最短距离--Floyd算法
- 冒泡排序
- Android 横竖屏的锁定
- WiFi Display
- oracle 10g函数大全--分析函数
- spring+ibatis【基本配置及动态sql】
- Android中onInterceptTouchEvent与onTouchEvent
- OpenWRT 增加内核模块及应用方法
- UNIX环境高级编程 apue.h头文件的配置
- 汇编assume 伪指令