Advertisement
NelloRizzo

[VBNET] Ordinamento Array

Feb 14th, 2017
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.72 KB | None | 0 0
  1. Module Module1
  2.  
  3.     Sub Sort(a() As Integer)
  4.         For index As Integer = 0 To a.Length - 2
  5.             For scan As Integer = index + 1 To a.Length - 1
  6.                 If a(index) > a(scan) Then
  7.                     Dim temp As Integer = a(index)
  8.                     a(index) = a(scan)
  9.                     a(scan) = temp
  10.                 End If
  11.             Next
  12.         Next
  13.     End Sub
  14.  
  15.     Sub Print(a() As Integer)
  16.         For Each i As Integer In a
  17.             Console.WriteLine(i)
  18.         Next
  19.     End Sub
  20.  
  21.     Sub Main()
  22.         Dim ar() As Integer = {123, 235, 3, 123, 37, 123, 356, 123, 87, 978}
  23.         Print(ar)
  24.         Sort(ar)
  25.         Print(ar)
  26.  
  27.         Console.ReadLine()
  28.     End Sub
  29.  
  30. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement