码迷,mamicode.com
首页 > 编程语言 > 详细

冒泡排序

时间:2019-11-17 17:25:27      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:技术   rgs   java   blog   info   mamicode   ring   print   void   

package blog;

import java.util.Arrays;

public class bubble {

	public static void main(String[] args) {
		int[] a = new int[] {9,5,7,4,0,3};
		asc(a);
		System.out.println(Arrays.toString(a));
	}
	
	static void asc(int [] arr) {
		int temp;
		for(int i=0;i<arr.length-1;i++) {
			for(int j=0;j<arr.length-1-i;j++) {
				if(arr[j+1] < arr[j]) {
				    temp = arr[j];
					arr[j] = arr[j+1];
					arr[j+1] = temp;
				}
			}
		}
	}
}
技术图片

  

冒泡排序

标签:技术   rgs   java   blog   info   mamicode   ring   print   void   

原文地址:https://www.cnblogs.com/wangsihui/p/11877106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!