asp的随机数问题

zlcp520 2016-08-23 11:52:55
<%
function GetRnd(min,max)
Randomize
GetRnd=Int((max - min + 1) * Rnd + min)
end function

dim i,tj,max,bj,sj,zf
bj=-1
max=0
tj=0
for i = 0 to 99999
if tj>3 then
if GetRnd(0,9)>4 then
zf=bj
else
zf=GetRnd(0,1)
end if
else
zf=GetRnd(0,1)
end if

response.write "<br />" & zf
response.write "------"
if bj=-1 then
bj=zf
else
if bj=zf then
tj=tj+1
else
if tj>max then max=tj
bj=zf
tj=0
end if
end if

for j=0 to tj
response.write tj &"-"
next

next
response.write "<br /><br />" & max
%>

加Randomize 循环内总是循环重复.
不加.整页怎么刷新换浏览器都是一样的......
asp搞个随机数就不可能吗
...全文
349 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
浪子回头8 2016-08-27
  • 打赏
  • 举报
回复
<% option explicit '强制浏览器重新访问服务器下载页面,而不是从缓存读取页面 Response.Buffer = True Response.Expires = -1 Response.ExpiresAbsolute = Now() - 1 Response.Expires = 0 Response.CacheControl = "no-cache" '主要是使随机出现的图片数字随机 %>
孟子E章 2016-08-26
  • 打赏
  • 举报
回复
随机数那块代码是没有问题的,应该是你下面的代码逻辑问题。 function GetRnd(min,max) Randomize GetRnd=Int((max - min + 1) * Rnd + min) end function for i = 0 to 9 response.write "<h3>" & GetRnd(0,9999) & "</h3>" next for i = 0 to 9 response.write "<h3>" & GetRnd(0,1) & "</h3>" next 测试来看随机的挺好的
zlcp520 2016-08-26
  • 打赏
  • 举报
回复

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧