冒泡排序:public class maopaouu { public static void main(String[] args) {
int a[] = {78, 23, 43, 56, 12, 65, 89, 98, 3, 124};
int i, j, n, temp;
n = a.length;
for (j = 1; j < n; j++) {
for (i = 0; i < n - j; i++) {
if (a[i] > a[i + 1]) {
temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
}
for (i = 0; i < n; i++) {
System.out.print(a[i]+" ");
}
}
}
最基础最方便的数组排序(伪)
SX
|
|