Skip to content

Instantly share code, notes, and snippets.

@uladzislau-slk
Created October 17, 2018 12:49
Show Gist options
  • Save uladzislau-slk/63ca7ebf48ef19e2ba5a5d93fabb1fdd to your computer and use it in GitHub Desktop.
Save uladzislau-slk/63ca7ebf48ef19e2ba5a5d93fabb1fdd to your computer and use it in GitHub Desktop.
Trying Kotlin
fun main(args: Array<String>) {
val nums: IntArray = intArrayOf(99, -10,100123,18,-978,5623,463,-9,287,49)
var size = 10
println("Исходный массив: ")
for (i in nums) print(" $i")
while (size > 0) {
(0 until size-1).forEach { i ->
if (nums[i] > nums[i+1]) {
var buf = nums[i]
nums[i] = nums[i+1]
nums[i+1] = buf
}
}
size--
}
println("\nОтсортированный массив: ")
for(i in nums) print(" $i")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment