- 论坛徽章:
- 0
|
public class Sort2
{
//交换排序之--最简单的冒泡排序法
public static void BubbleSort(int[] a)
{
int i,j,temp;
int n = a.length;
for(i=0;ia[j])
{
temp = a;
a = a[j];
a[j] = temp;
}
}
}
}
//插入排序-- 直接插入排序
public static void InsertSort(int[] a)
{
int i,j,temp;
int n = a.length;
for(i=1;itemp)&&(j>=0))
{
a[j+1] = a[j];
j--;
}
a[j+1] = temp;
}
}
//选择排序
public static void SelectSort(int[] a)
{
int i,j,min,temp;
int n=a.length;
for(i=0;i
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/65478/showart_1077215.html |
|