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

07.24(数组)冒泡法排序

时间:2017-07-24 21:22:08      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:font   int   冒泡   method   public   sys   length   oid   todo   

public class 冒泡排序法 {

public static void main(String[] args) {
// TODO Auto-generated method stub
int []a= {89,50,84,57,61,20,86};                // 7个元素;
for (int i=0;i<a.length-1;i++)
{
for(int j=0;j<a.length-1;j++)
{
if(a[j]>a[j+1]) {
int m;
m=a[j];
a[j]=a[j+1];
a[j+1]=m;
}
}
}
for (int i=0;i<a.length;i++)
{
System.out.println(a[i]);
}
}

}

07.24(数组)冒泡法排序

标签:font   int   冒泡   method   public   sys   length   oid   todo   

原文地址:http://www.cnblogs.com/sunyuanlong/p/7230843.html

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