public class bubbleSort{
public static void main(String args[]){
int a[] = {49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51123, 43, 454, 4546, 5454, 4656, 45657, 2343, 565436, 465765};
int temp = 0;
for(int i = 0; i < a.length - 1; i++){
for(int j = 0; j < a.length - 1 - i; j++){
if(a[j] > a[j + 1]){
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
for(int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
}
}
java 冒泡排序
最新推荐文章于 2025-05-22 17:55:03 发布