[파일명:  TestSortApp.bas]------------------------------------------------
Imports System
Imports System.Collections
Imports System.Collections.Generic

Namespace MyTestApplication1

    Public Class TestSortApp

        ' Java 언어의 main 메소드에 해당하는 Visual Basic의 Main
        Shared Sub Main(ByVal args As String())
            Dim arr(args.Length) As String
            Dim i As Integer
            For i = 0 To args.Length - 1
                arr(i) = args(i)
            Next i
            Array.Sort(arr)
            PrintArray(arr)
        End Sub

        Shared Sub PrintArray(arr As Object())
            Dim i As Integer
            Console.Write("[")
            For i = 1 To arr.Length - 2
                Console.Write("{0}, ", arr(i))
            Next i
            If arr.Length > 0 Then
                Console.Write("{0}", arr(arr.Length - 1))
            End If
            Console.WriteLine("]")
        End Sub
    End Class
End Namespace
------------------------------------------------


컴파일> vbc TestSortApp.bas

실행> TestSortApp one two three four five
[five, four, one, three, two]

실행> TestSortApp 하나 둘 셋 넷 다섯
[넷, 다섯, 둘, 셋, 하나]


 

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Scripter
,