import java.util.Arrays;
public class Bubble {
public static void main(String[] args) {
int b[] = {8,6,7,5,3,5,2};
int c = b.length;
int t = 0;
for(int i = 1; i < c; i++){
for(int j = 0; j < c-i; j++){
if(b[j] > b[j+1]){
t = b[j];
b[j] = b[j+1];
b[j+1] = t;
}
}
}
System.out.println(Arrays.toString(b));
}
}
java描述冒泡排序(个人随笔)
最新推荐文章于 2024-08-14 23:12:09 发布