We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 402cf8e + ae27b4c commit 07f4033Copy full SHA for 07f4033
Searching and Sorting/Bubble Sort/Kotlin/BubbleSort.kt
@@ -0,0 +1,27 @@
1
+import java.util.*
2
+fun bubbleSort(arr:IntArray){
3
+ for(i in 0 until arr.size-1){
4
+ for(j in 0 until arr.size-i-1){
5
+ if(arr[j]>arr[j+1]){
6
+ var temp = arr[j]
7
+ arr[j] = arr[j+1]
8
+ arr[j+1] = temp
9
+ }
10
11
12
+}
13
+fun main(args:Array<String>) {
14
+ var scanner = Scanner(System.`in`)
15
+ print("enter the size to be sorted ")
16
+ var sizeOfList = scanner.nextInt()
17
+ val array = IntArray(sizeOfList)
18
+ print("start entering values to be sorted ")
19
+ for (i in 0 until sizeOfList) {
20
+ array[i] = scanner.nextInt();
21
22
+ bubbleSort(array)
23
+ for (i in 0 until sizeOfList){
24
+ print(array[i])
25
+ print(" ")
26
27
0 commit comments