java描述冒泡排序(个人随笔)

import java.util.Arrays;
public class Bubble {
	public static void main(String[] args) {
		int b[] = {8,6,7,5,3,5,2};
		int c = b.length;
		int t = 0;
		for(int i = 1; i < c; i++){
			for(int j = 0; j < c-i; j++){
				if(b[j] > b[j+1]){
					t = b[j];
					b[j] = b[j+1];
					b[j+1] = t;
				}
			}
		}
		System.out.println(Arrays.toString(b));
	}

}

你可能感兴趣的:(Java,java,冒泡排序)