设为首页 加入收藏

TOP

冒泡排序JAVA实现
2014-11-24 02:41:07 来源: 作者: 【 】 浏览:2
Tags:冒泡 排序 JAVA 实现

冒泡排序JAVA实现


public class MaoPao {


/**
* @冒泡排序
*/


static int arry[];


//交换元素方法
public static void huan(int one,int two){
int temp=arry[one];
arry[one]=arry[two];
arry[two]=temp;

}


//显示输出数组中的数据
public static void output(){
for(int i=0;i System.out.print(arry[i]+" ");
}
}


//核心排序方法
public static void paixu(){
for(int a=arry.length-1;a>1;a--){
for(int b=0;b if(arry[b]>arry[b+1]){
huan(b, b+1);
}
}

}

}


public static void main(String[] args) {
arry=new int[]{1,5,3,9,23,14,12,35};
System.out.print("-----原始数据:----:");
output();
paixu();
System.out.println(" ");
System.out.print("-----排序后数据:----:");
output();


}


}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux下静态编译的一个TIP 下一篇汉诺塔算法JAVA版

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: