public class BubbleSort {
public static void main(String[] args){
int[] array={49,38,65,97,76,13,27};
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];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
System.out.println("排序后的顺序为:");
for(int num:array)
{
System.out.print(num+" ");
}
}
}
冒泡排序java篇
最新推荐文章于 2024-06-07 09:15:00 发布