Java 冒泡排序算法實現
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]+" ");
} }</pre>
本文由用戶 w43m 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!