Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a083a7

Browse files
SD Array BUBBLE Sort - VB Code
Visual Basic 2010 Code for Bubble Sort on SD Array. Using Reverse Loop and FLAG for robustness...
1 parent 861fc3d commit 1a083a7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

‎SDArrBubbleSortRobust.vb‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Module Module1
2+
Sub Main()
3+
Dim Array(10), count As Integer
4+
For count = 1 To 10
5+
Array(count) = Console.ReadLine()
6+
Next
7+
Call Bubblesort(Array, 10)
8+
9+
For count = 1 To 10
10+
Console.WriteLine(Array(count))
11+
Next
12+
Console.ReadKey()
13+
End Sub
14+
Sub Bubblesort(ByVal Array() As Integer, ByVal Length As Integer)
15+
Dim isSorted As Boolean
16+
Dim I As Integer
17+
Dim J As Integer
18+
Dim Temp As Integer
19+
isSorted = True
20+
For I = Length - 1 To 1 Step -1 'last element of array does'nt get sorted.
21+
isSorted = True
22+
For J = 0 To I '- 1
23+
If Array(J) > Array(J + 1) Then ' Compare neighboring elements
24+
Temp = Array(J)
25+
Array(J) = Array(J + 1)
26+
Array(J + 1) = Temp
27+
isSorted = False
28+
End If
29+
Next
30+
If isSorted = True Then Exit For
31+
Next
32+
End Sub
33+
End Module

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /