冒泡排序

package com.jin.www;
import java.util.Arrays;

public class one {
	public static void main(String[] args) {
		int mathone=0;
		int []math= {1,3,4,21,343,12,431,12,23,-12};
		for(int i=0;i<math.length-1;i++) {
			for(int j=0;j<math.length-1;j++) {
				if(math[j]>math[j+1]) {
					mathone=math[j+1];
					math[j+1]=math[j];
					math[j]=mathone;
				}
			}
		}
		System.out.println(Arrays.toString(math));
	}
}
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页