首页 > 编程语言 > 详细

冒泡排序

时间:2017-08-26 02:25:32      阅读:301      评论:0      收藏:0      [点我收藏+]
/**
* Created by IntelliJ IDEA.
* Author: 付石强.
* Date: 2017/8/25.
* Time: 下午8:42.
* {2,9,1,4,10,18} 将数组降序输出
*/
public class Array {
public static void main(String[] args) {
int[] array = {2, 9, 1, 4, 10, 18};
for (int i = 0; i < array.length; i++) {
for (int j = i + 1; j < array.length; j++) {
if (array[i] < array[j]) {
int temp =array[i];

            array[i] = array[j];

            array[j] = temp;
                }
}
System.out.println(array[i]);
}
}
}

冒泡排序

原文:http://www.cnblogs.com/f-s-q/p/7429823.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!