java选择排序Selection Sort
来源:互联网 发布:java环境变量怎么设置 编辑:程序博客网 时间:2024/05/19 08:40
java选择排序Selection Sort
顾名思义,就是直接从待排序数组里选择一个最小(或者最大的数字),每次都拿一个最小数字出来,顺序放入数组,直到全部拿完
public class SelectIionSort { static void selectionSort(int[] intArray){ int flag = -1; for (int i = 0; i < intArray.length-1; i++) { int min = intArray[i]; for (int j = i; j < intArray.length; j++) { if(intArray[j]<min){ min = intArray[j]; flag = j; } } if(flag != -1){ intArray[flag] = intArray[i]; intArray[i] = min; } } } public static void main(String[] args) { int[] intArray = {2,5,6,9,4,3,5,9,8}; selectionSort(intArray); for (int i = 0; i < intArray.length; i++) { System.out.println(intArray[i]); } }}
源文件下载
0 0
- java选择排序Selection Sort
- 选择排序(selection sort)
- 选择排序(Selection Sort)
- selection sort 选择排序
- 选择排序 Selection Sort
- 选择排序(Selection Sort)
- 选择排序(Selection Sort)
- 选择排序 (Selection Sort)
- 选择排序(Selection sort)
- 选择排序 (Selection sort)
- 选择排序Selection sort
- Selection Sort(选择排序)
- 选择排序(Selection Sort)
- Selection Sort选择排序
- selection sort 选择排序
- selection sort(选择排序)
- Selection sort 选择排序
- 选择排序Selection sort
- 关于Linux Diff命令
- java方法延时执行
- 四个刷掉菜鸟iOS方法
- 图算法—Problem K
- Linux内核中ctags的安装及使用方法
- java选择排序Selection Sort
- ThinkPHP3.2自制的一个分页
- 项目上有红叉,程序没有红叉的解决办法
- oracle中创建主键以及添加主键
- POJ 1475 Pushing Boxes(BFS)
- Deep Residual Learning for Image Recognition(ResNet)论文笔记
- Gson的简单用法
- 求最大公约数——辗转相除法,更相减损术
- Listview的优化