[Java] java冒泡排序 →→→→→进入此内容的聊天室

来自 , 2019-02-05, 写在 Java, 查看 153 次.
URL http://www.code666.cn/view/b4a52895
  1. package org.rut.util.algorithm.support;
  2. import org.rut.util.algorithm.SortUtil;
  3. /**
  4.  * @author treeroot
  5.  * @since 2006-2-2
  6.  * @version 1.0
  7.  */
  8. public class BubbleSort implements SortUtil.Sort{
  9.     /* (non-Javadoc)
  10.      * @see org.rut.util.algorithm.SortUtil.Sort#sort(int[])
  11.      */
  12.     public void sort(int[] data) {
  13.         int temp;
  14.         for(int i=0;i<data.length;i++){
  15.             for(int j=data.length-1;j>i;j--){
  16.                 if(data[j]<data[j-1]){
  17.                     SortUtil.swap(data,j,j-1);
  18.                 }
  19.             }
  20.         }
  21.     }
  22. }

回复 "java冒泡排序"

这儿你可以回复上面这条便签

captcha