Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Option Explicit On
- Module BubleSort
- Sub Main()
- Dim txt As String
- Dim n As Integer
- Dim x As Integer
- Console.Write("Enter the number of elements in the array n= ")
- txt = Console.ReadLine()
- If (Integer.TryParse(txt, n)) Then
- Dim a(n - 1) As Integer
- For index = 0 To a.GetUpperBound(0)
- Console.Write("a({0})=", index)
- a(index) = CInt(Console.ReadLine())
- Next
- 'sortirane
- For row = 1 To a.Length - 1
- For i = 0 To a.Length - 2
- If a(i) > a(i + 1) Then
- x = a(i)
- a(i) = a(i + 1)
- a(i + 1) = x
- End If
- Next i
- Next row
- txt = ""
- For index = 0 To a.Length - 1
- txt = txt & a(index) & vbNewLine
- Next
- Console.WriteLine(txt)
- End If
- Console.ReadKey()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment