Created
October 17, 2018 12:49
-
-
Save uladzislau-slk/63ca7ebf48ef19e2ba5a5d93fabb1fdd to your computer and use it in GitHub Desktop.
Trying Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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