写一个冒泡排序算法,先写出测试代码,再完成排序算法

来源:百度知道 编辑:UC知道 时间:2024/09/20 18:47:35
用JAVA语言来写..麻烦各位大哥了

package org.rut.util.algorithm.support;

import org.rut.util.algorithm.SortUtil;

/**
* @author treeroot
* @since 2006-2-2
* @version 1.0
*/
public class BubbleSort implements SortUtil.Sort{

/* (non-Javadoc)
* @see org.rut.util.algorithm.SortUtil.Sort#sort(int[])
*/
public void sort(int[] data) {
int temp;
for(int i=0;i<data.length;i++){
for(int j=data.length-1;j>i;j--){
if(data[j]<data[j-1]){
SortUtil.swap(data,j,j-1);
}
}
}
}

}

http://www.pconline.com.cn/pcedu/empolder/gj/java/0603/772297.html