复制代码 代码如下:
Function makegroup(teams() As String) As String
'函数功能:对teams数组中的32支球队进行随机分组.(注:teams数组下标从0开始)
'函数的变量定义.
'显示变量声明是一个好习惯.
Dim tvar As Integer, returnstr As String, tmove As Integer, temp As Integer
'初始化随机数产生器实现真正的随机性.
Randomize (Timer)
For tvar = 1 To 32 '共有32支球队
If (tvar - 1) Mod 4 = 0 Then
'将分组球队名称及组名存入returnstr变量中.
returnstr = returnstr & vbCrLf & Chr(Asc("A") + (tvar \ 4)) & "组:"
End If
tmove = Int(Rnd * (33 - tvar))
returnstr = returnstr & teams(tmove) & "."
For temp = tmove To 30
'将数组的部分前移避免组中存在同名球队.
teams(temp) = teams(temp + 1)
Next temp
Next tvar
'返回值为分组后的结果.
makegroup = returnstr
End Function
Function makegroup(teams() As String) As String
'函数功能:对teams数组中的32支球队进行随机分组.(注:teams数组下标从0开始)
'函数的变量定义.
'显示变量声明是一个好习惯.
Dim tvar As Integer, returnstr As String, tmove As Integer, temp As Integer
'初始化随机数产生器实现真正的随机性.
Randomize (Timer)
For tvar = 1 To 32 '共有32支球队
If (tvar - 1) Mod 4 = 0 Then
'将分组球队名称及组名存入returnstr变量中.
returnstr = returnstr & vbCrLf & Chr(Asc("A") + (tvar \ 4)) & "组:"
End If
tmove = Int(Rnd * (33 - tvar))
returnstr = returnstr & teams(tmove) & "."
For temp = tmove To 30
'将数组的部分前移避免组中存在同名球队.
teams(temp) = teams(temp + 1)
Next temp
Next tvar
'返回值为分组后的结果.
makegroup = returnstr
End Function
标签:
asp中实现随机分组程序的代码
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“asp中实现随机分组程序的代码”评论...