标签:style blog color for ar div log new sp
package com.learning.algorithm; public class BubbleSort { public int[] bubbleSort1(int[] arrValue){ int temp =0; int length = arrValue.length; for(int i=length-1;i>1;i--){ for(int j=0;j<i;j++){ if(arrValue[j]>arrValue[j+1]){ temp = arrValue[j]; arrValue[j] = arrValue[j+1]; arrValue[j+1] = temp; } } } return arrValue; } public int[] bubbleSort2(int[] arrValue){ int temp = 0; int length = arrValue.length; for(int i=0;i<length-1;i++){ for(int j=0;j<length-1-i;j++){ if(arrValue[j]>arrValue[j+1]){ temp = arrValue[j]; arrValue[j] = arrValue[j+1]; arrValue[j+1] = temp; } } } return arrValue; } public static void main(String[] args) { int[] arrValue = {89,39,56,93,2,58,43,51,33,67}; BubbleSort bs = new BubbleSort(); int[] arrResult = bs.bubbleSort1(arrValue); for(int value:arrResult){ System.out.print(value); System.out.print(","); } System.out.println(); System.out.println("--------------------------------"); int[] arrResult1 = bs.bubbleSort1(arrValue); for(int value:arrResult1){ System.out.print(value); System.out.print(","); } } }
标签:style blog color for ar div log new sp
原文地址:http://www.cnblogs.com/ryanwangblog/p/3931521.html