选择排序优化三点
来源:互联网 发布:北航软件学院毕业生 编辑:程序博客网 时间:2024/04/30 10:34
public void ChoiceSort(string[] arrPrice)
{//优化3点:arrPrice.Length -1(最后一次不用比较了)、j = i + 1(已经比较过了)、if (minIndex != i)不用交换
Double temp = 0;
int minIndex = 0;
for (int i = 0; i < arrPrice.Length -1; i++)
{
minIndex = i;
for (int j = i + 1; j < arrPrice.Length; j++)
{
if (Convert.ToDouble(arrPrice[j]) < Convert.ToDouble(arrPrice[minIndex]))
{
minIndex = j;
}
}
if (minIndex != i)
{
temp = Convert.ToDouble(arrPrice[minIndex]);
arrPrice[minIndex] = arrPrice[i];
arrPrice[i] = Convert.ToString(temp);
}
}
}
0 0
- 选择排序优化三点
- 排序(三)-选择排序
- 排序三:选择排序
- 选择排序的优化
- 选择排序极其优化
- 选择排序优化算法
- 选择排序及其优化
- 优化的选择排序
- 选择排序及优化
- 三点排序
- 排序三之选择排序
- 层层优化的选择排序
- 选择排序法及其优化
- 选择排序法的优化
- 选择排序的优化算法
- 选择排序法及其优化
- 选择排序及其优化方案
- 选择排序法的优化
- C++11 线程库(高层接口)
- 批量合并excel工作表
- UIday11
- servlet为什么要配置web.xml
- matlab自动输出数据到excel文件的指定单元格
- 选择排序优化三点
- 远程连接SQL Server 2008,服务器端和客户端配置
- 求长度
- DFS之全排列
- Z.N 工作室
- matlab 指针数据转换为数组数据,用于求平均值、最大值
- 【HEVC学习与研究】29、解码第一个Coding Quadtree结构(1)
- 自动运行多个matlab算例
- 关于sql中索引的优缺点(面试常考)