彩票随机生成器原型

o_babyt_copyright2.gif

以后买彩票的时候可以用用,哈哈
不过还存在不少细节问题,比如说逻辑控制不严密等等
这个等谁用的时候自己去改改吧

 

None.gif < %
None.gif
' *************************************************************************
None.gif'
**文件名称:Lottery.asp
None.gif'
**功能描述:彩票随机生成器模型
None.gif'
            本程序为程序原型,未进行校验和保护及美化
None.gif'
            程序默认为你按照正常规则操作
None.gif'
**全局变量:
None.gif'
**调用模块:
None.gif'
**作    者:Babyt(阿泰)
None.gif'
**日    期:2005-04-08
None.gif'
**修 改 人:
None.gif'
**日    期:
None.gif'
**版    本:V1.0.0
None.gif'
版权:原创
None.gif'
授权:免费共享
None.gif'
Url: http://www.cnblogs.com/babyt
None.gif'
*************************************************************************
None.gif
Randomize
None.gif
Dim  iStep
None.gifiStep
= Request( " step " )
None.gif
If  iStep = ""   Then  iStep = " 0"
None.gif
Select   Case  iStep
None.gif    
' 初始界面
None.gif
     Case   " 0"
None.gif
     ' 生成后的界面
None.gif
        % >
None.gif        
< Form method = post >
None.gif            彩票机生成器
< BR >
None.gif            本程序为模型,未进行校验和保护
< BR >             
None.gif            彩球总数 
< input  type = " input "  size = 10  maxlength = 2  value = " 35 "  name = " a1 " >  
None.gif            开奖球数 
< input  type = " input "  size = 10  maxlength = 1  value = " 7 "  name = " a2 " >  
None.gif            
< input  type = " hidden "  name = " step "  value = " 1 " >
None.gif            
< input  type = " submit "  value = " 生成 " >
None.gif        
</ Form >
None.gif        
< %
None.gif    
Case   " 1"
None.gif
         ' 选取后的界面(可以回退到前一界面重新选取)    
None.gif
         Dim  iAll,iSelect,i
None.gif        iAll
= Request( " a1 " )
None.gif        iSelect
= Request( " a2 " )
None.gif        %
>
None.gif        
< font color = red >< % = iAll% ></ font > < font color = blue >< % = iSelect% ></ font >< BR >
None.gif        
< Form method = post >
None.gif        本程序为模型,未进行校验和保护
< BR >
None.gif        如果必选和必不选中选中了同样的数字,则默认为选中,不进行提示
< BR >
None.gif        注意,您选择的不选条件越多,生成的速度会越慢
< BR >
None.gif        
< input  type = " submit "  value = " 开始随机生成 " >
None.gif        
< HR size = 1 >
None.gif        必选:
< BR >
None.gif        
< %
None.gif        
For  i = 1   To  iAll
None.gif            %
>
None.gif            
< input  type = " checkbox "  name = s1 value = " <%=i%> " >< % = i% >& nbsp; & nbsp;
None.gif            
< %
None.gif            
If  i  Mod   10   = 0   Then  Response. Write   " <BR>"
None.gif
         Next
None.gif        %
>
None.gif        
< HR >
None.gif        必不选:
< BR >
None.gif        
< %
None.gif        
For  i = 1   To  iAll
None.gif            %
>
None.gif            
< input  type = " checkbox "  name = s2 value = " <%=i%> " >< % = i% >& nbsp; & nbsp;
None.gif            
< %
None.gif            
If  i  Mod   10   = 0    Then  Response. Write   " <BR>"
None.gif
         Next
None.gif        %
>
None.gif        
< input  type = " hidden "  name = " step "  value = " 2 " >
None.gif        
< input  type = " hidden "  name = " a1 "  value = " <%=iAll%> " >
None.gif        
< input  type = " hidden "  name = " a2 "  value = " <%=iSelect%> " >
None.gif        
</ Form >
None.gif        
< %
None.gif    
Case   " 2"
None.gif
         ' 使用字串而不使用数组提高对比速度
None.gif
         Dim  sS1,sS2,aS1,aS2,iS1,iCount,xrnd
None.gif        iAll
= Request( " a1 " )
None.gif        iSelect
= Request( " a2 " )
None.gif        
None.gif        
' 替换里面可能存在的空格
None.gif
        sS1 = Replace (Request.Form( " s1 " ), "   " , "" )
None.gif        sS2
= Replace (Request.Form( " s2 " ), "   " , "" )
None.gif        
None.gif        Response.
Write  iAll  &   " "   &  iSelect  &   " <BR>"
None.gif
        Response. Write   " 必选: "   &  sS1  &   " <BR>"
None.gif
        Response. Write   " 必不选: "   &  sS2  &   " <BR>"
None.gif
        
None.gif        sS2
=   " , "   &  sS2  &   " ,"
None.gif
         ' 判断必选的个数
None.gif
         ' iS1为需要选取的个数
None.gif
         If  sS1 = ""   Then
None.gif            iS1
= iSelect
None.gif        
Else
None.gif            aS1
= Split (sS1, " , " )    
None.gif            
' 重新组织sS1                        
None.gif
            sS1 =   " , "   &  sS1  &   " , "             
None.gif            iS1
= iSelect  -   Ubound (aS1) - 1     
None.gif            
' Response.Write "dddd" & iS1
None.gif
         End   If
None.gif        
' 开始生成
None.gif
        iCount = 0
None.gif        
Call  GenNumber
None.gif        
' Response.Write "选取结果:<font color=red>" & Mid(sS1,2,Len(sS1)-2) & "</font><BR>"
None.gif
        
None.gif        
' 把结果进行排序
None.gif
        sS1 = Mid (sS1, 2 , Len (sS1) - 2 )
None.gif        
Dim  sReturn,arrS
None.gif        arrS
= Split (sS1, " , " )
None.gif        
Call  SortIt()
None.gif        
For  i = 0   To   UBound (arrS)
None.gif            sReturn 
=  sReturn  &  arrS(i)  &   " ,"
None.gif
         Next
None.gif        Response.
Write   Left (sReturn, Len (sReturn) - 1 )
None.gif    
End   Select
None.gif
None.gif
' 数字生成
ExpandedBlockStart.gifContractedBlock.gif
Function GenNumber() Function GenNumber()
InBlock.gif    
Randomize
InBlock.gif    xrnd
=Cint(RND*(iAll+1))
InBlock.gif    
If xRnd>=1 And xRnd<=iAll Then
InBlock.gif        
'如果不在必选的范围内,则继续
InBlock.gif
        If Instr(1,sS1, "," & xRnd & ",",1)<=0 Then
InBlock.gif            
'如果不在必不选的范围内,则继续
InBlock.gif
            If Instr(1,sS2, "," & xRnd & ",",1)<=0 Then
InBlock.gif                
'组合成已选字串
InBlock.gif
                sS1=sS1 & xRnd & ","
InBlock.gif
                iCount=iCount+1
InBlock.gif                
If iCount>=iS1 Then                                    
InBlock.gif                    
Exit Function
InBlock.gif                
End If
InBlock.gif            
End If
InBlock.gif        
End If                
InBlock.gif    
End If
InBlock.gif    
'递归
InBlock.gif
    GenNumber
ExpandedBlockEnd.gif
End Function

None.gif
None.gif
' 数组排序
ExpandedBlockStart.gifContractedBlock.gif
Function SortIt() Function SortIt()
InBlock.gif    
Dim i,s0,iCount,j
InBlock.gif    iCount
=0
InBlock.gif    
For i=0 To UBound(arrS)
InBlock.gif        
If i+1<=UBound(arrS) Then
InBlock.gif            
If CInt(arrS(i))>Cint(arrS(i+1)) Then
InBlock.gif                s0
=arrS(i)
InBlock.gif                arrS(i)
=arrS(i+1)
InBlock.gif                arrS(i
+1)=s0
InBlock.gif                iCount
=iCount+1
InBlock.gif            
End If
InBlock.gif        
End If
InBlock.gif    
Next
InBlock.gif    
If iCount=0 Then Exit Function
InBlock.gif    
'递归
InBlock.gif
    SortIt()
ExpandedBlockEnd.gif
End Function

None.gif%
>
None.gif
None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值