|
<body> <form action=randomarray.asp method=post> Max : <input type=text name=nummax size=5 value=999> <br> Min : <input type=text name=nummin size=5 value=1> <br> Amt : <input type=text name=numamt size=5 value=15> <br> <input type=submit value=Random><input type=reset value=Reset> </form> <% numamt = int(request.form("numamt")) nummax = int(request.form("nummax")) nummin = int(request.form("nummin")) ' แก้ไขบรรทัดข้างล่างนี้ โดยเติม +1 เข้าไป เพราะจะผิดคุณสมบัติของ max,min if numamt > (nummax - nummin + 1) or numamt = 0 or numamt > 999 then response.write( "Invalid command") else randomize dim arr(999) i = 1 do while i <= numamt x = int(nummin + (rnd * ( nummax - nummin + 1))) found = 0 for j = 1 to i - 1 if arr(j) = x then found = 1 next if found = 0 then arr(i) = x i = i + 1 end if loop for k = 1 to numamt response.write( arr(k) & "<br>") next erase arr end if %> </body> |