public class ArraySort {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[] = { 100, 3, 0, 4, 5, 7, 23, 22, 33, 35, 76, 3, 32, 32, 98 };
System.out.println("目标数组为:");
print(a);
System.out.println("冒泡排序后的数组为:");
print(bubbleSort(a));
System.out.println("选择排序后的数组为:");
print(selectSort(a));
System.out.println("插入排序后的数组为:");
print(insertSort(a));
System.out.println("快速排序之后的数组为:");
print(quickSort(a, 0, a.length-1));
}
// 冒泡排序
public static int[] bubbleSort(int data[]) {
for (int i = 0; i < data.length; i++) {
int temp = 0;
for (int j = 0; j < data.length - i - 1; j++) {
if (data[j] > data[j + 1]) {
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载