排序
来源:互联网 发布:威纶触摸屏数据导出 编辑:程序博客网 时间:2024/06/06 00:19
冒泡:
public static void MaoPao() { int[] arrList = { 1, 2, 6, 8, 3, 4, 5,12,9,14,29,16 }; for (int i = 0; i < arrList.Length ; i++) { int temp = arrList[i]; for (int j = i + 1; j < arrList.Length; j++) { if (temp > arrList[j]) { arrList[i] = arrList[j]; arrList[j] = temp; temp = arrList[i]; } } } foreach (var item in arrList) { Console.WriteLine("冒泡结果{0}", item); } int[] arr = { 1, 2, 6, 8, 3, 4, 5, 12, 9, 14, 29, 16 }; for (int i = 0; i <= arr.Length - 1; i++) { for (int j = arr.Length - 1; j > i; j--) { if ((int)arr[j] < (int)arr[j - 1]) { int temp = (int)arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; } } } foreach (var item in arr) { Console.WriteLine("冒泡结果{0}", item); } }
阅读全文
0 0
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- 排序
- ZeroMQ在Win7下的编译
- AndroidFlux
- 小米-懂二进制 华为-最高分是多少
- Quartz任务调度(4)JobListener分版本超详细解析
- 消息队列应用场景
- 排序
- Hibernate专题6——注解配置
- TCP服务器的单进程实现
- HDU 6024 Building Shops(DP)
- Linux-环境变量与文件查找
- [BZOJ4917][Lydsy六月份月赛 .A][模拟]Hash Killer IV
- Ubuntu安装jdk7或者jdk8
- 欢迎使用CSDN-markdown编辑器
- Linux shell 经验手册__001__常识