scala冒泡排序代码
时间: 2023-03-08 19:58:22 浏览: 85
冒泡排序代码
我的scala冒泡排序代码如下:object BubbleSort {def bubbleSort(arr: Array[Int]): Unit = {for(i ← 0 until arr.length - 1; j ← 0 until arr.length - 1 - i) {if (arr(j) > arr(j + 1)) {val tmp = arr(j)arr(j) = arr(j + 1)arr(j + 1) = tmp}}} }
阅读全文