Random(随机函数)的使用

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import=
"java.util.ArrayList"%>
<%@ page import=
"java.util.Random"%>

<form method=
"post" name="frms" action="check.jsp">
<table width=
"180" height="140"  border="0" align="center" cellpadding="0" cellspacing="0">  
        <%
          
            ArrayList  a = new ArrayList();
            ArrayList  b = new ArrayList();
            StringBuffer ss = new StringBuffer();
            StringBuffer us = new StringBuffer();
            Random r = new Random();
            String gs=
"";
            String logo0[];
            int cn=15;
    
String logos =
"logo";

for(int i = 0;i<15;i++){
                logo0=new String[5];
                logo0[0]=logos+
"0["+i+"]";
                logo0[1]=logos+
"1["+i+"]";
                logo0[2]=logos+
"2["+i+"]";
logo0[3]=logos+
"3["+i+"]";
logo0[04]=logos+
"4["+i+"]";
                a.add(logo0);
            }
            int jc=0;
            while(a.size()>0){
                jc = r.nextInt(a.size());
                b.add(a.get(jc));
                a.remove(jc);
            }
            int is=0;
            for(int j=0;j<5;j++){
        %>
        <tr>
          <td height=
"12">&nbsp;</td>
        </tr>
        <tr>
            <%
                for(int i=0;i<3;i++){
                    is++;
                    logo0=(String[])b.get(j*3+i);

            %>
            <td align=
"center"><table width="160" height="110"  border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td><table width=
"142" height="100"  border="1" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td align=
"center" valign="middle" ><img style="cursor:hand" onClick="subl(<%=is%>,<%=logo0[0]%>)" src="<%=logo0[2]%>" title="点我进行游戏" width="120" height="60" border="0"><br>
                        <br>
                        <a href=
"<%=logo0[4]%>" target="_blank" class="font21"><%=logo0[1]%></a></td>
                  </tr>
                  <tr>
                    <td align=
"center" valign="middle" ><input name="funs" type="checkbox" id="funs" value="<%=logo0[2]%>"></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
            <%}%>
        </tr>
        <%}%>  
</table>
<div align=
"center"><br>
    <input type=
"submit" name="Submit" value="提交">
</div>
</form>
lunzi   2006-11-26 17:02:43 评论:0   阅读:1294   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog