class Demo02
{
/*
冒泡排序
两两数据元素比较,得出最大的数据元素
*/
public static void main(String[] args)
{
int[] num={4,3,1,8,5};
BobbleSort(num);
}
public static void BobbleSort(int[] arr)
{
for (int i=0;i
arr[j+1])
{
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
PrintArray(arr);
}
public static void PrintArray(int[] Arr)
{
for (int i=0;i
冒泡排序——java语言
最新推荐文章于 2023-06-12 18:14:10 发布