Java 冒泡排序算法实现
2018-07-20 来源:open-open
public class BubbleSort {
public static void sortiere(int[] x) {
boolean unsortiert=true;
int temp;
while (unsortiert){
unsortiert = false;
for (int i=0; i < x.length-1; i++)
if (x[i] > x[i+1]) {
temp = x[i];
x[i] = x[i+1];
x[i+1] = temp;
unsortiert = true;
}
}
}
public static void main(String[] args) {
int[] liste = {0,9,4,6,2,8,5,1,7,3};
sortiere(liste);
for (int i=0; i<liste.length; i++)
System.out.print(liste[i]+" ");
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:Java 线程池测试类
最新资讯
热门推荐