标题:请班主帮忙<ASP在线考试系统的一个判断题随机出题>这二段代码各表示什么?烦 ...
只看楼主
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1519
专家分:174
注 册:2006-6-3
结帖率:79.3%
 问题点数:0 回复次数:9 
请班主帮忙<ASP在线考试系统的一个判断题随机出题>这二段代码各表示什么?烦死人了
这个是关于ASP在线考试系统的一个判断题随机出题算法```下面各表示什么意思?好象有重复

randomize
sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)

while rst.eof
randomize

sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)
wend



[ 本帖最后由 sylknb 于 2010-4-6 18:19 编辑 ]
搜索更多相关主题的帖子: 班主 ASP 考试 系统 随机 
2010-04-06 11:25
zhuyunshen
Rank: 6Rank: 6
等 级:侠之大者
威 望:2
帖 子:212
专家分:455
注 册:2009-11-22
得分:0 
不会ASP
2010-04-06 12:40
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1519
专家分:174
注 册:2006-6-3
得分:0 
没有人解答呀!等急!
2010-04-06 18:19
xchengo
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-17
得分:0 
随机数的函数,应该是随机抽题
2010-04-17 23:03
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
randomize
sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)

while rst.eof
randomize'初始化随机函数VB中随机数开始时的初始化。

sid=int(maxtype1*rnd+1)'生成一个随机数的算法,这个随机数是一个题目的编号,用这个编号读取一个题目
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)
wend
2010-04-18 16:12
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1519
专家分:174
注 册:2006-6-3
得分:0 
randomize
sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)

while rst.eof
randomize

sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)
wend

我的意思是红的一段已随机了,为什么兰的一段还要来一个循环再来一次随机?
2010-04-18 16:57
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
randomize
sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)

while rst.eof
randomize

sid=int(maxtype1*rnd+1)
set rst=conn.execute("select * from rightorwrong where rightorwrongid="&sid)
wend
两次循环的确不太对,因为楼主提供的代码太少,无法得知2次循环的目的。
而且从现有代码来看,这么循环极有可能造成无限循环,或者服务器当机。
2010-04-18 17:13
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1519
专家分:174
注 册:2006-6-3
得分:0 
附全部代码:用红色标识的表示不理介的地方,为什么要有二次随机数
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<%
flagpd=0
flagxz=0
flagtk=0
randomize
set rss=conn.execute("select top 1 * from report where 学生id="&session("id")&" and (是否补考=no or 补考成绩<>0) order by id desc ")
if rss.eof then
qi=1
else
qi=rss("id")+1
end if
set rss=conn.execute("select top 1 * from report where 学生id="&session("id")&" and (是否补考=yes and  补考成绩=0) order by id desc ")
if not rss.eof then
qi=rss("id")
end if


set rss=conn.execute("select top 1 * from test order by id desc")
if rss.eof then
%>
<script language=javascript>
alert("请先出题!再进行考试!");
history.back();
</script>
<%
else
pd=rss("判断题数")
pds=rss("判断题每题分数")
xz=rss("选择题数")
xzs=rss("选择题每题分数")
tk=rss("填空题数")
tks=rss("填空题每题分数")
session("EndTime")=rss("考试时间")
zf=pd*pds+xz*xzs+tk*tks
testid=rss("id")

set rs=conn.execute("select top 1 * from type1 order by id desc")
maxtype1=rs("id")
set rs=conn.execute("select top 1 * from type2 order by id desc")
maxtype2=rs("id")
set rs=conn.execute("select top 1 * from type3 order by id desc")
maxtype3=rs("id")

sqlfind="select * from report where 试卷id="&testid&" and 学生id="&session("id")&" and (是否补考=False or 补考成绩<>0)"
set rsfind=conn.execute (sqlfind)
if not rsfind.eof then

%>
<script language=javascript>
alert("你已经参加过这次考试了,请等待下一次考试!");
window.navigate("index.asp");
</script>
<%else
if Session("startTime") = "" then
    NowTime = Now()
    Session("startTime") = NowTime
end if
set rsfinds=conn.execute("select * from report where 试卷id="&testid&" and 学生id="&session("id")&" and (是否补考=True and  补考成绩=0)")
if not rsfinds.eof then
else
sqlin="insert into report (id,试卷id,学生id,分数) values("&qi&","&testid&","&session("id")&",0)"
'response.write sqlin
'response.end
set rsin=conn.execute(sqlin)
end if
end if
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上考试系统</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>

<body topmargin="0" leftmargin="0">
<!--#include file = "top.htm" -->

<table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" height ="100" align="center">  
  <tr>
    <td align="center"><font class=test1>第 <%=qi%> 期考试</font>
   
     <br>(本期考试 <%=pd%> 道判断题,<%=xz%>  道选择题,<%=tk%> 道填空题,总分 <%=zf%> 分)
     
            </td>
        </tr>
        <tr>
        <td align="center"><!--#include file="js2.asp" -->
        </td>
        </tr><form name="form1" action="test_over.asp" method="post">
        <tr>

 
    <td align="center" bgcolor="#CBEFDC"><font color="#000080"><input type="hidden" name=qi value=<%=qi%>>  
    <input type="hidden" name=testid value=<%=testid%>>
        <input type="hidden" name=pd value=<%=pd%>>  
     <input type="hidden" name=xz value=<%=xz%>>  
            <input type="hidden" name=tk value=<%=tk%>>  
                <input type="hidden" name=zf value=<%=zf%>>  
                <input type="hidden" name=pds value=<%=pds%>>  
            <input type="hidden" name=xzs value=<%=xzs%>>  
                <input type="hidden" name=tks value=<%=tks%>>考生姓名:<%=session("student")%>&nbsp;&nbsp; 性别: <%=session("sex")%> &nbsp; 班级:<%=session("classes")%>&nbsp;&nbsp;&nbsp; 学号:<%=session("number")%></font></td>
    </tr>
    <tr>
    <td align="center">
    <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750" align="center">  
    <tr>  
      <td bgcolor="#CBEFDC">一、判断题(共 <%=pd%> 道,每题 <%=pds%> 分)</td>  
  </tr>  
  <%  
      if pd=0 then  
        Response.write "<input type='hidden' name=messagepd value='本次考无判断题'>"  
        flagpd=1  
   %>
    <tr>  
      <td align=center>本次不考判断题</td>  
    </tr>  
    <%   
    else  
        for i=1 to pd  
            if maxtype1=0 then  
          Response.write "<input type='hidden' name=messagepd value='题库里暂无判断题'>"  
      flagpd=1  
    %>
    <tr>  
        <td align=center>题库里暂无判断题</td>  
  </tr>  
    <%  
            else  
                 randomize  
                sid=int((maxtype1+1)*rnd+1)  
                set rst=conn.execute("select * from type1 where id="&sid)  
              while rst.eof  
                    randomize  
                  sid=int((maxtype1+1)*rnd+1)  
                    set rst=conn.execute("select * from type1 where id="&sid)  
                wend
   
    %>  
    <tr>  
      <td>&nbsp;&nbsp;&nbsp; <%=i%>、<%=rst("题干")%>  
          <input type="hidden" name="tgpd<%=i%>" value="<%=rst("题干")%>">  
          <select name="cate<%=i%>" size="1" style="background-color: rgb(224,252,255)">  
          <option selected value=True>对</option>  
          <option value=False>错</option></select>  
          <input type="hidden" name="pdda<%=i%>" value="<%=rst("正确答案")%>">  
        </td>  
    </tr>  
  <%  
      end if   
    next  
   end if %>                              
</table>  
<br>  
<table align="center" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
        <tr>  
          <td bgcolor="#CBEFDC">二、选择题(共 <%=xz%> 道,每题 <%=xzs%> 分)</td>  
        </tr>  
          <%if xz=0 then  
                  response.write "<input type='hidden' name=messagexz value='本次考无选择题'>"  
        flagxz=1  
        %><tr>  
          <td align=center>本次考无选择题  
          </td>  
        </tr>  
    <%else  
    for i=1 to xz
    if maxtype2=0 then  
                      response.write "<input type='hidden' name=messagexz value='题库里暂无选择题'>"  
    flagxz=1  
    %><tr>  
          <td align=center>题库里暂无选择题  
          </td>  
        </tr>  
    <%else  
    randomize  
    sid=int((maxtype2+1)*rnd+1)  
    set rst=conn.execute("select * from type2 where id="&sid)  
    while rst.eof  
    randomize  
  
    sid=int((maxtype2+1)*rnd+1)  
    set rst=conn.execute("select * from type2 where id="&sid)  
      
    wend  
    %>  
  
        <tr>  
          <td>&nbsp;&nbsp;&nbsp; <%=i%>、<%=rst("题干")%>  
          <input type="hidden" name="tgxz<%=i%>" value="<%=rst("题干")%>"></td>  
        </tr>  
        
        <tr>  
          <td>  
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
            <input  type="radio" value="A" name="sele<%=i%>"> A.<%=rst("选项1")%>&nbsp;&nbsp;  
<input type="hidden" name="xzxx1<%=i%>" value="<%=rst("选项1")%>" >   
  
            <input  type="radio" value="B" name="sele<%=i%>"> B.<%=rst("选项2")%>&nbsp;  
<input type="hidden" name="xzxx2<%=i%>" value="<%=rst("选项2")%>" >   
              
            <input  type="radio" value="C" name="sele<%=i%>"> C.<%=rst("选项3")%>&nbsp;&nbsp;  
            <input type="hidden" name="xzxx3<%=i%>" value="<%=rst("选项3")%>" >   
  
            <input  type="radio" value="D" name="sele<%=i%>"> D.<%=rst("选项4")%>   
            <input type="hidden" name="xzxx4<%=i%>" value="<%=rst("选项4")%>" >   
  
<input type="hidden" name="xzda<%=i%>" value="<%=rst("正确答案")%>" >   
          </td>  
        </tr>  
          <%  
        end if   
        next  
        end if %>  
        </table>  
      </center>  
    </div>  
<br>  
    <div align="center">  
      <center>  
      <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
        <tr>  
          <td bgcolor="#CBEFDC">三、填空题(共 <%=tk%> 道,每题 <%=tks%> 分)</td>  
        </tr>  
         <%if tk=0 then  
                      response.write "<input type='hidden' name=messagetk value='本次考无填空题'>"  
        flagtk=1  
        %><tr>  
          <td align=center>本次考无填空题  
            
          </td>  
        </tr>  
    <%else  
    for i=1 to tk  
    if maxtype3=0 then  
                      response.write "<input type='hidden' name=messagetk value='题库里暂无填空题'>"  
    flagtk=1  
    %><tr>  
          <td align=center>题库里暂无填空题  
          </td>  
        </tr>  
    <%else  
    randomize  
    sid=int((maxtype3+1)*rnd+1)  
    set rst=conn.execute("select * from type3 where id="&sid)  
    while rst.eof  
    randomize  
  
    sid=int((maxtype3+1)*rnd+1)  
    set rst=conn.execute("select * from type3 where id="&sid)  
      
      
    wend  
      
    %>  
  
        <tr>  
          <td>&nbsp;&nbsp;&nbsp; <%=i%>、<%=rst("题干")%>  
          <input type="hidden" name="tgtk<%=i%>" value="<%=rst("题干")%>">  
          &nbsp; 您的答案:<input type="text" name="T<%=i%>" size="20" class="line"></td>  
<input type="hidden" name="tkda<%=i%>" value="<%=rst("正确答案")%>">  
        </tr>  
         <%  
        end if   
        next  
        end if %>  
         
        </table>  
   
      </center>  
    </div>  
    <br>
        <input type="hidden" name="flagpd" value=<%= flagpd %>>
        <input type="hidden" name="flagxz" value=<%= flagxz %>>
        <input type="hidden" name="flagtk" value=<%= flagtk %>>  
      <input type="submit" value="提交" name="B1">
            <input type="reset" value="重置" name="B2">  
    <p>  
    <br>
 
    </td>  
  </tr>  
</table>  
</form>  
  </center>  
</div>  
<!--#include file="adv.htm"-->  
</body>  
  
</html>  
<%end if %>

[ 本帖最后由 sylknb 于 2010-4-21 17:34 编辑 ]
2010-04-21 17:33
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<%
flagpd=0
flagxz=0
flagtk=0
randomize
set rss=conn.execute("select top 1 * from report where 学生id="&session("id")&" and (是否补考=no or 补考成绩<>0) order by id desc ")
if rss.eof then
   qi=1
else
   qi=rss("id")+1
end if
set rss=conn.execute("select top 1 * from report where 学生id="&session("id")&" and (是否补考=yes and  补考成绩=0) order by id desc ")
if not rss.eof then
   qi=rss("id")
end if
set rss=conn.execute("select top 1 * from test order by id desc")
if rss.eof then
%>
  <script language=javascript>
    alert("请先出题!再进行考试!");
    history.back();
  </script>
<%
else
  pd=rss("判断题数")
  pds=rss("判断题每题分数")
  xz=rss("选择题数")
  xzs=rss("选择题每题分数")
  tk=rss("填空题数")
  tks=rss("填空题每题分数")
  session("EndTime")=rss("考试时间")
  zf=pd*pds+xz*xzs+tk*tks
  testid=rss("id")
  set rs=conn.execute("select top 1 * from type1 order by id desc")
  maxtype1=rs("id")
  set rs=conn.execute("select top 1 * from type2 order by id desc")
  maxtype2=rs("id")
  set rs=conn.execute("select top 1 * from type3 order by id desc")
  maxtype3=rs("id")
  sqlfind="select * from report where 试卷id="&testid&" and 学生id="&session("id")&" and (是否补考=False or 补考成绩<>0)"
  set rsfind=conn.execute (sqlfind)
  if not rsfind.eof then
  %>
    <script language=javascript>
      alert("你已经参加过这次考试了,请等待下一次考试!");
      window.navigate("index.asp");
    </script>
  <%
  else
     if Session("startTime") = "" then
        NowTime = Now()
        Session("startTime") = NowTime
     end if
     set rsfinds=conn.execute("select * from report where 试卷id="&testid&" and 学生id="&session("id")&" and (是否补考=True and  补考成绩=0)")
     if not rsfinds.eof then
     else
        sqlin="insert into report (id,试卷id,学生id,分数) values("&qi&","&testid&","&session("id")&",0)"
        'response.write sqlin
        'response.end
        set rsin=conn.execute(sqlin)
     end if
  end if
%>
<html>
<head>
  <meta http-equiv="Content-Language" content="zh-cn">
  <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
  <meta name="ProgId" content="FrontPage.Editor.Document">
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  <title>网上考试系统</title>
  <link rel="stylesheet" type="text/css" href="css.css">
</head>
<body topmargin="0" leftmargin="0">
  <!--#include file = "top.htm" -->
  <table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" height ="100" align="center">  
    <tr>
     <td align="center">
       <font class=test1>第 <%=qi%> 期考试</font>
       <br>(本期考试 <%=pd%> 道判断题,<%=xz%>  道选择题,<%=tk%> 道填空题,总分 <%=zf%> 分)
     </td>
   </tr>
   <tr>
      <td align="center">
        <!--#include file="js2.asp" -->
      </td>
   </tr>
      <form name="form1" action="test_over.asp" method="post">
        <tr>
         <td align="center" bgcolor="#CBEFDC">
          <font color="#000080">
          <input type="hidden" name=qi value=<%=qi%>>  
          <input type="hidden" name=testid value=<%=testid%>>
          <input type="hidden" name=pd value=<%=pd%>>  
          <input type="hidden" name=xz value=<%=xz%>>  
          <input type="hidden" name=tk value=<%=tk%>>  
          <input type="hidden" name=zf value=<%=zf%>>  
          <input type="hidden" name=pds value=<%=pds%>>  
          <input type="hidden" name=xzs value=<%=xzs%>>  
          <input type="hidden" name=tks value=<%=tks%>>
          考生姓名:<%=session("student")%>&nbsp;&nbsp;
          性别: <%=session("sex")%> &nbsp;
          班级:<%=session("classes")%>&nbsp;&nbsp;&nbsp;
          学号:<%=session("number")%></font>
        </td>
     </tr>
     <tr>
      <td align="center">
        <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750" align="center">  
          <tr>  
            <td bgcolor="#CBEFDC">
              一、判断题(共 <%=pd%> 道,每题 <%=pds%> 分)
            </td>  
         </tr>  
        <%  
        if pd=0 then  
           Response.write "<input type='hidden' name=messagepd value='本次考无判断题'>"  
           flagpd=1  
           %>
          <tr>  
            <td align=center>本次不考判断题</td>  
          </tr>  
          <%   
       else  
          for i=1 to pd  
              if maxtype1=0 then  
                 Response.write "<input type='hidden' name=messagepd value='题库里暂无判断题'>"  
                 flagpd=1  
                 %>
                 <tr>  
                  <td align=center>题库里暂无判断题</td>  
                 </tr>  
                 <%  
             else  
                randomize  
                sid=int((maxtype1+1)*rnd+1)  
                set rst=conn.execute("select * from type1 where id="&sid)  
                while rst.eof  
                      randomize  
                      sid=int((maxtype1+1)*rnd+1)  
                      set rst=conn.execute("select * from type1 where id="&sid)  
                wend   
                %>  
                <tr>  
                 <td>
                   &nbsp;&nbsp;&nbsp; <%=i%>、<%=rst("题干")%>  
                   <input type="hidden" name="tgpd<%=i%>" value="<%=rst("题干")%>">  
                   <select name="cate<%=i%>" size="1" style="background-color: rgb(224,252,255)">  
                      <option selected value=True>对</option>  
                      <option value=False>错</option>
                  </select>  
                  <input type="hidden" name="pdda<%=i%>" value="<%=rst("正确答案")%>">  
                 </td>  
               </tr>  
              <%  
          end if   
       next  
    end if %>                              
</table>  
<br>  
<table align="center" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
  <tr>  
     <td bgcolor="#CBEFDC">二、选择题(共 <%=xz%> 道,每题 <%=xzs%> 分)</td>  
  </tr>  
  <%
     if xz=0 then  
        response.write "<input type='hidden' name=messagexz value='本次考无选择题'>"  
        flagxz=1  
  %>
  <tr>  
     <td align=center>
      本次考无选择题  
     </td>  
   </tr>  
<%
else  
    for i=1 to xz
        if maxtype2=0 then  
           response.write "<input type='hidden' name=messagexz value='题库里暂无选择题'>"  
          flagxz=1  
          %>
          <tr>  
            <td align=center>
              题库里暂无选择题  
            </td>  
          </tr>  
          <%
          else  
            randomize  
            sid=int((maxtype2+1)*rnd+1)  
            set rst=conn.execute("select * from type2 where id="&sid)  
            while rst.eof  
                randomize  
                sid=int((maxtype2+1)*rnd+1)  
                set rst=conn.execute("select * from type2 where id="&sid)  
            wend  
         %>  
        <tr>  
          <td>
            &nbsp;&nbsp;&nbsp; <%=i%>、<%=rst("题干")%>  
            <input type="hidden" name="tgxz<%=i%>" value="<%=rst("题干")%>">
          </td>  
        </tr>  
        <tr>  
          <td>  
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
            <input  type="radio" value="A" name="sele<%=i%>">
            A.<%=rst("选项1")%>&nbsp;&nbsp;  
            <input type="hidden" name="xzxx1<%=i%>" value="<%=rst("选项1")%>" >   
            <input  type="radio" value="B" name="sele<%=i%>">
            B.<%=rst("选项2")%>&nbsp;  
           <input type="hidden" name="xzxx2<%=i%>" value="<%=rst("选项2")%>" >   
           <input  type="radio" value="C" name="sele<%=i%>">
           C.<%=rst("选项3")%>&nbsp;&nbsp;  
           <input type="hidden" name="xzxx3<%=i%>" value="<%=rst("选项3")%>" >   
           <input  type="radio" value="D" name="sele<%=i%>">
           D.<%=rst("选项4")%>   
           <input type="hidden" name="xzxx4<%=i%>" value="<%=rst("选项4")%>" >   
           <input type="hidden" name="xzda<%=i%>" value="<%=rst("正确答案")%>" >   
          </td>  
        </tr>  
        <%  
     end if   
  next  
end if
%>  
   </table>  
  </center>  
</div>  
<br>  
<div align="center">  
   <center>  
      <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
        <tr>  
          <td bgcolor="#CBEFDC">
            三、填空题(共 <%=tk%> 道,每题 <%=tks%> 分)
          </td>  
        </tr>  
        <%
           if tk=0 then  
              response.write "<input type='hidden' name=messagetk value='本次考无填空题'>"  
              flagtk=1  
              %>
             <tr>  
               <td align=center>
                本次考无填空题  
              </td>  
            </tr>  
           <%
          else  
            for i=1 to tk  
                if maxtype3=0 then  
                   response.write "<input type='hidden' name=messagetk value='题库里暂无填空题'>"  
                   flagtk=1  
                   %>
                  <tr>  
                    <td align=center>
                      题库里暂无填空题  
                    </td>  
                  </tr>  
                  <%
               else  
                 randomize  
                 sid=int((maxtype3+1)*rnd+1)  
                 set rst=conn.execute("select * from type3 where id="&sid)  
                 while rst.eof  
                    randomize  
                    sid=int((maxtype3+1)*rnd+1)  
                    set rst=conn.execute("select * from type3 where id="&sid)  
                 wend
              %>  
             <tr>  
              <td>
                &nbsp;&nbsp;&nbsp; <%=i%>、<%=rst("题干")%>  
                <input type="hidden" name="tgtk<%=i%>" value="<%=rst("题干")%>">  
                &nbsp; 您的答案:<input type="text" name="T<%=i%>" size="20" class="line">
             </td>  
             <input type="hidden" name="tkda<%=i%>" value="<%=rst("正确答案")%>">  
           </tr>  
          <%  
          end if   
      next  
   end if
   %>  
       </table>  
      </center>  
     </div>  
     <br>
     <input type="hidden" name="flagpd" value=<%= flagpd %>>
     <input type="hidden" name="flagxz" value=<%= flagxz %>>
     <input type="hidden" name="flagtk" value=<%= flagtk %>>  
     <input type="submit" value="提交" name="B1">
     <input type="reset" value="重置" name="B2">  
     <p>  
     <br>
     </td>  
    </tr>  
   </table>  
  </form>  
 </center>  
 </div>  
 <!--#include file="adv.htm"-->  
</body>  
</html>  
<%
end if
%>
                 randomize  
                 sid=int((maxtype3+1)*rnd+1)  
                 set rst=conn.execute("select * from type3 where id="&sid)  
                 while rst.eof  
                    randomize  
                    sid=int((maxtype3+1)*rnd+1)  
                    set rst=conn.execute("select * from type3 where id="&sid)  
                 wend
看了一下代码大致明白了二次随机数的目的,一次随机数只产生一个提干,再循环时容易出现重复,所以增加一个循环产生一个二次随机数,两次循环后题干就不会重复出现了。
2010-04-21 18:36
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1519
专家分:174
注 册:2006-6-3
得分:0 
谢谢!
2010-04-22 17:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-301840-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.102907 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved