Rabu, 26 September 2012

VISUAL BASIC deret

Private Sub Form_Activate()
Dim i, j, n, Min As Integer
Dim A(5) As Integer

A(1) = 5
A(2) = 3
A(3) = 1
A(4) = 7
A(5) = 9
Print "angka sebelum diurutkan"
For i = 1 To 5
    Print "angka ke "; i; "="; A(i)
Next i
n = 4
For i = 1 To n
    Min = i
For j = i + 1 To 5
    If A(Min) > A(j) Then
    Min = j
    End If
Next j
    temp = A(i)
    A(i) = A(Min)
    A(Min) = temp
Next i
Print
Print "angka setelah diurutkan"
For j = 1 To 5
    Print "angka ke"; j; "="; A(j)
Next j
End Sub

Tidak ada komentar:

Posting Komentar