本帖最后由 大绯狼 于 2011-4-6 19:38 编辑
现在在做一个棋牌游戏的辅助,里面的玩法需要一个从5个数字里选出3个数的操作,一个人的思路有限,看看大家 ...
foboy 发表于 2011-3-15 12:59
肥猪牛解决法$tenstring = "118" & @CRLF & "127" & @CRLF & "136" & @CRLF & "145" & @CRLF & "19x" & @CRLF & "226" & @CRLF & "235" & @CRLF & "244" & @CRLF & "28x" & @CRLF & "299" & @CRLF & "334" & @CRLF & "37x" & @CRLF & "389" & @CRLF & "46x" & @CRLF & "479" & @CRLF & "488" & @CRLF & "55x" & @CRLF & "569" & @CRLF & "578" & @CRLF & "668" & @CRLF & "677"& @CRLF&"xxx"
For $k = 1 To 100
$g_array = ''
$time = TimerInit()
For $i = 0 To 4
$temp = Random(1, 10, 1)
If $temp = 10 Then $temp = 'x'
$g_array &= $temp
Next
$fin = ten($g_array)
If $fin = True Then ConsoleWrite(TimerDiff($time) & @CRLF)
Next
Func ten($array)
If StringRegExp($tenstring, '[' & $array & ']{3}', 0) = 1 Then Return True
Return False
EndFunc ;==>ten
我的破电脑上的效率0.0354793695846818
0.0338031788956418
0.0346412742401618
0.0307301626324016
0.0312888928620816
0.0611809601499632
0.0254222254504413
0.0307301626324016
0.0318476230917617
0.0321269882066017
0.0312888928620816
0.0279365114840015
0.0273777812543214
0.0301714324027216
0.0273777812543214
0.0254222254504413
0.0276571463691614
0.0270984161394814
0.0315682579769217
0.0318476230917617
0.0290539719433615
0.0321269882066017
0.0298920672878816
0.0284952417136815
0.0298920672878816
0.165104782870449
0.0312888928620816
0.0326857184362817
0.0290539719433615
0.0284952417136815
0.0265396859098014
0.0282158765988415
0.0301714324027216
0.0259809556801214
0.0296127021730415
0.0265396859098014
0.0282158765988415
0.0631365159538433
0.0282158765988415
0.0296127021730415
0.075987311236484
0.0257015905652813
0.0421841323408422
0.0290539719433615
0.0293333370582015
0.0290539719433615
0.0544761973938028
0.0298920672878816
0.0310095277472416
0.0276571463691614
0.0541968322789628
0.0284952417136815
0.0268190510246414
0.0284952417136815
0.0279365114840015
0.0301714324027216
0.0270984161394814
0.119009538921846
0.0287746068285215
0.0270984161394814
0.0296127021730415
0.0273777812543214
0.0287746068285215
0.0315682579769217
0.0268190510246414
0.0276571463691614
0.0265396859098014
0.0270984161394814
0.0276571463691614
0.0310095277472416
0.0290539719433615
0.0318476230917617
0.0340825440104818
0.0293333370582015
0.0324063533214417
0.0472127044079625
0.0346412742401618
0.0544761973938028
0.0290539719433615
0.0561523880828429
0.143593669027767
0.296965117074936
0.0265396859098014
0.237739712728852
0.281320670643895
0.0276571463691614
0.262044477719934
0.0326857184362817
0.0282158765988415
0.0293333370582015
0.429663546623942
照理说纯数字运算会快很多 不过做字符串对比应该也不会太慢 这种小量的数据其实没有必要考虑效率的 没有什么差别 |