public class xuanZePaiXu {
public static void main(String[] args) {
int[] a = { 2, 6, 4, 5, 1, 7, 3 };
for (int i = 0; i < a.length; i++) {
int temp = 0;
for (int j = i + 1; j < a.length; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for (int t : a) {
System.out.println(t + ",");
}
}
}
|
|