<%
dim numamt, nummax, nummin, ar(100), itmp, jtmp, ktmp
numamt = 5 : nummax = 100 : nummin = 50
response.write("Before sorted by shell sort<br>")
randomize
for i = 1 to numamt
ar(i) = int(nummin + (rnd * ( nummax - nummin + 1 )))
response.write( i & " : " & ar(i) & "<br>")
next
itmp = 1
for j = 2 to numamt
jtmp=ar(j)
ktmp= j - 1
if itmp = 0 then
itmp = itmp + 1
ar(itmp) = jtmp
end if
do while jtmp < ar(ktmp) and ktmp > 0 and ktmp <= numamt
ar(ktmp + 1) = ar(ktmp)
ktmp = ktmp - 1
loop
ar(ktmp + 1) = jtmp
next
response.write("<hr>After sorted by shell sort<br>")
for i = 1 to numamt
response.write( i & " : " & ar(i) & "<br>")
next
%>
จำนวน : 28 บรรทัด