📄 selectionsort.java
字号:
public class SelectionSort //选择
{
private double[] unsorted;
private double[] sorted;
public SelectionSort()
{
}
public SelectionSort(double[] temp)
{
setdata(temp);
sort();
}
public void setdata(double[] temp)
{
unsorted=new double[temp.length];
sorted=new double[temp.length];
for(int i=0;i<temp.length;i++)
{
sorted[i]=unsorted[i]=temp[i];
//System.out.println(sorted[i]);
}
}
public void sort()
{
int n=sorted.length;
double temp=sorted[0];
int tar=0;
while(n>1)
{
temp=sorted[0];
tar=0;
for(int j=0;j<n;j++)
{
if(sorted[j]>temp)
{
temp=sorted[j];
tar=j;
}
}
n--;
sorted[tar]=sorted[n];
sorted[n]=temp;
}
}
public double[] getresult()
{
return sorted;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -