{
//交換排序之
public static void BubbleSort(int[] a)
{
int i
int n = a
for(i=
{
for(j=i+
{
if (a[i]>a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
//插入排序
public static void InsertSort(int[] a)
{
int i
int n = a
for(i=
{
temp = a[i];
j=i
while((a[j]>temp)&&(j>=
{
a[j+
j
}
a[j+
}
}
//選擇排序
public static void SelectSort(int[] a)
{
int i
int n=a
for(i=
{
min = a[i];
for(j=i+
{
if(a[j]<min)
{
temp = min;
min =a[j];
a[j] = temp;
}
}
a[i] =min ;
}
}
public static void main(String[] args)
{
int[] arr = {
int n = arr
BubbleSort(arr)
for(int i=
System
System
InsertSort(arr)
for(int i=
System
System
SelectSort(arr)
for(int i=
System
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25722.html