您的位置:首页 > 其它

简单的选择排序(内部排序)

2015-03-01 22:37 246 查看
package com.trfizeng.test;

import com.trfizeng.insertionsort.StraightInsertionSort;
import com.trfizeng.selectionsort.SimpleSelectionSort;

/**
* 测试类
*
* @author trfizeng
*
*/
public class SortTest {
// 待排序数组
static int[] array = new int[] { 6, 1, 4, 10, 11, 8, 7, 1, 0 };

/**
* 直接插入排序法测试
*/
public static void straightInsertionSortTest() {
System.out.print("待排序数组:[ ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.print("]   ");

array = StraightInsertionSort.straightInsertionSort(array);
System.out.print("排好序的数组:[ ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.print("]");
}

/**
* 选择排序
*/
public static void simpleSelectionSort() {
System.out.print("待排序数组:[ ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.print("]   ");

array = SimpleSelectionSort.simpleSelectionSort(array);
System.out.print("排好序的数组:[ ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.print("]");

}

public static void main(String[] args) {
// SortTest.straightInsertionSortTest();

SortTest.simpleSelectionSort();

}
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: