Thursday, January 20, 2011

RECURSIVE ARRAY 1

'----- Program Utama -----
CALL InputVectorDariRandom(x,N)
CALL CetakVectorKeSamping(x,N,"x","Isi Vektor :")
document.write "Nilai Maximal = " & maxHC(x,N) & "
"

'----- Koleksi Modul -----
SUB InputVectorDariKeyboard(byRef v(), byRef N)
N = cint(InputBox("Masukkan Jumlah Elemen Array"))
REDIM v(N)
FOR i=1 TO N
v(i) = cint(InputBox("Masukkan Isi Elemen ke-" & i))
NEXT
END SUB

SUB InputVectorDariRandom(byRef v(), byRef N)
N = cint(InputBox("Masukkan Jumlah Elemen Array"))
REDIM v(N)
FOR i=1 TO N
v(i) = 100 + int(rnd*900)
NEXT
END SUB

SUB CetakVector(byVal v(), byVal N, byVal nama, byVal message)
document.write "
" & message & "
"
FOR i=1 TO N
document.write nama & "(" & i & ") = " & v(i) & "
"
NEXT
END SUB

SUB CetakVectorKeSamping(byVal v(), byVal N, byVal nama, byVal message)
document.write "
" & message & "
"
FOR i=1 TO N
document.write v(i) & ", "
NEXT
document.write "
"
END SUB

FUNCTION maxHC(byVal v(), byVal N)
maxHC = -1
FOR c=1 TO N
IF v(c)>maxHC THEN maxHC=v(c)
NEXT
END FUNCTION

No comments:

Post a Comment