找回密码
 加入
搜索
楼主: foboy

[效率算法] 求一算法

 火.. [复制链接]
发表于 2011-4-6 10:05:02 | 显示全部楼层
看看算法 学习下
发表于 2011-4-6 17:03:38 | 显示全部楼层
本帖最后由 大绯狼 于 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
照理说纯数字运算会快很多 不过做字符串对比应该也不会太慢 这种小量的数据其实没有必要考虑效率的 没有什么差别
发表于 2019-8-10 16:22:36 | 显示全部楼层
支持一下,像楼主学习一下
发表于 2019-8-10 17:03:20 | 显示全部楼层
楼主辛苦了,谢谢楼主,感谢楼主分享,楼主好人一生平安!!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 21:23 , Processed in 0.119055 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表