选择排序
来源:互联网 发布:阿里云云数据网站 编辑:程序博客网 时间:2024/05/21 13:22
public class Select {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[]={1,5,3,2,4,2343,65,12,23,12};
Sort(a);
for(int l :a){
System.out.println(l);
}
}
public static void Sort(int[] a){
int temp;
for(int i=0;i<a.length;i++)
{
int index=getMinIndex(a,i);
if (index!=i)
{
temp=a[i];
a[i]=a[index];
a[index]=temp;
}
}
}
public static int getMinIndex(int a[],int i){
int min=a[i];
int index=i;
for (int f=index;f<a.length;f++)
{
if(a[f]<min)
{
min=a[f];
index=f;
}
}
return index;
}
}
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序:
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- ETL学习笔记之一:ETL是什么?
- WCF之Endpoint详解
- wine-qq
- 简单的拓扑排序(POJ2367)
- MFC消息循环2,分解RunModalLoop
- 选择排序
- ETL学习笔记之二:ETL与BI
- Mother's Milk
- ETL学习笔记之三:MS SQL DTS
- 程序员之打油诗
- WCF之元数据交换 (Metadata Exchange)
- 【转载】网络协议学习方法和工具
- Proguard.cfg(the file can't find) 解决方法
- 观感默认设置相关文件swing.properties的设置问题