CALL InputVectorDariRandom(X,N)
document.write" Metode pengurutan data dengan Selection Sort
"
document.write "
"
CALL Cetak(x,n," Sebelum Sorting :")
CALL SelectionSort(x,n)
CALL Cetak(x,n," Setelah Sorting :")
SUB InputVectorDariRandom(byRef v(), byRef N)
RANDOMIZE
N = cint(InputBox("Masukkan Jumlah Elemen Array"))
REDIM v(N)
FOR c=1 TO N
v(c)=10+int(rnd*90)
NEXT
END SUB
SUB SelectionSort(byRef v(), byVal jumlah)
FOR i=1 TO jumlah-1
MIN = i
FOR j=I+1 TO jumlah
IF v(j)< v ( MIN ) THEN MIN=j
NEXT
IF i<>MIN THEN
temp=v(i)
v(i)=v(MIN)
v(MIN)=temp
END IF
NEXT
END SUB
SUB Cetak(byVal v(), byVal N, message)
document.write "Isi Vektor " & message & "
"
FOR c=1 TO N
document.write v(c) & ", "
NEXT
document.write "
"
document.write "
"
END SUB
No comments:
Post a Comment