选择排序(selection sort)
来源:互联网 发布:阿里数据分析师待遇 编辑:程序博客网 时间:2024/06/05 16:02
首先创建一个辅助函数:寻找a[0:n-1]中的最大元素的位置indexOfMax
int indexOfMax(int a[], int n){ int aa = 0; for(int i = 1; i < n; i++) { if(a[aa] < a[i]) { aa = i; } } return aa;}
选择排序主函数:
//选择排序void selectionSort(int a[], int n){ for(int size = n; size > 1; size --) { int j = indexOfMax(a,size); swap(a[j],a[size-1]); }}
阅读全文
0 0
- 选择排序(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(选择排序)
- TCP三次握手与四次挥手
- PS图片压缩教程,教你快速压缩jpg图片文件的大小而又不失真!
- Android MediaCodec硬解码H264文件
- 在不同版本python下安装tensorflow
- WIFI (热点)打开和关闭
- 选择排序(selection sort)
- 求各位帮我设计一个三极管开关电路(以SS8050)为例,具体要求看问题补充.多谢
- R数据结构
- 仿微信语音聊天
- Akka(11): 分布式运算:集群-均衡负载
- java 图上传
- CocoaPod
- 解决ISCROLL单击变双击的BUG
- [leetcode]62. Unique Paths(Java)