📄 selectionsort.java
字号:
public class SelectionSort {
public static void bubble(double[] a) {
double temp;
for(int i=0;i<a.length-1;i++)
{
for(int j=0;j<a.length-1-i;j++)
{
if(a[j] < a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
public static void main(String[] args) {
for(int N=100;N<=1000000;N*=10)
{
long start;
long stop;
double elapsed;
double[] a = new double[N];
for (int i = 0; i < N; i++)
a[i] = i;
// sort them
start = System.currentTimeMillis();
bubble(a);
stop = System.currentTimeMillis();
elapsed = (stop - start) ;
//print the time
System.out.println("Selection: " + elapsed + " seconds");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -