import java
.util
.Arrays
;
class MP {
public static void Mppx(int[] array
) {
boolean flg
= false;
for (int i
= 0; i
< array
.length
- 1; i
++) {
for (int j
= 0; j
< array
.length
- 1 - i
; j
++) {
if (array
[j
] > array
[j
+ 1]) {
int temp
= array
[j
+ 1];
array
[j
+ 1] = array
[j
];
array
[j
] = temp
;
flg
= true;
}
}
if (flg
= false) {
return;
}
}
}
public static void main(String
[] args
) {
int[] array
= {9, 5, 2, 7, 12, 10, 1, 4, 23};
Mppx(array
);
System
.out
.println(Arrays
.toString(array
));
}
}
==============================================
输出结果:
[1, 2, 4, 5, 7, 9, 10, 12, 23]
转载请注明原文地址: https://mac.8miu.com/read-516597.html