冒泡排序(一)

public class BubbleSort {

	public static void main(String[] args) {
		// 定义数组
		int[] a = { 49, 38, 65, 97, 76, 13, 27, 49, 78, 34, 12, 64, 1 };
		
		for (int i = 0; i < a.length-1; i++) {
			for (int j = 0; j < a.length-1-i; j++) {
				if (a[j] > a[j+1]) {
					int temp = a[j+1];
					a[j+1] = a[j];
					a[j] = temp;
				}
			}
		}
		
	
	}
}

猜你喜欢

转载自blog.csdn.net/JINGhl512/article/details/83651907