package XQ; public class BianLiErWeiShuZu { public static void main(String[] args) { int[] A = new int[] { 6, 9, 8, 3, 5, 2 }; int C = 0; for (int D = 1; D < A.length; D++) { for (int B = 1; B < A.length-D+1; B++) { if (A[B - 1] > A[B]) { C = A[B - 1]; A[B - 1] = A[B]; A[B] = C; } } for (int B = 1; B < A.length+1; B++) { System.out.print(A[B - 1]+" "); } System.out.println(); } } }
时间: 2024-10-24 22:44:13