欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

算法实现系列第一章.冒泡排序

程序员文章站 2022-06-05 16:29:11
...

package algorithm;

public class Bubbling { 
	public static void main(String[] args) {
		int[] ints = {123,1,31,31,432,42,1,23,556,75,67,76,8,6} ;
		int temp = 0  ;
		for (int i = 0; i < ints.length; i++) {
			for (int j = i; j < ints.length; j++) {
				if(ints[i]<ints[j]){
					temp = ints[i] ;
					ints[i] = ints[j] ;
					ints[j] = temp ; 
				}
			}
		}
		
		for (int i = 0; i < ints.length; i++) {
			System.out.println(ints[i]);
		}
	}
}
 不要问不解释.