Welcome to Yumao′s Blog.
/**冒泡排序*/
import java.util.Arrays;
public class Maopao {
public static void main(String[] args){
int[] a = {4,2,5,7,1};
int x =0;
for(int i=0;ia[j+1]){
x=a[j];
a[j]=a[j+1];
a[j+1]=x;
}
}
}
System.out.println(Arrays.toString(a));
}
}
/**選擇排序*/
package paixu;
import java.util.Arrays;
public class Xuanzhe {
public static void main(String[] args) {
int[] a = {1,2,5,6,4};
int x = 0;
for(int i=0;ia[j]){
x=a[i];
a[i]=a[j];
a[j]=x;
}
}
}
System.out.println(Arrays.toString(a));
}
}
/**插入排序*/
public class Charu
{
public static void main(String[] args)
{
int ary[]={1,5,8,5,4,9,3,2,8,2,3,7,1};
int temp,j;
System.out.println(System.currentTimeMillis());
for(int i=1;i=0 && temp