本帖最后由 gto250 于 2011-5-11 18:07 编辑
$begin = TimerInit()
$a="123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430123456789012345698765432107654301234567890123456987654321076543012345678901234569876543210765430"
$b="95412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123580125789685469870125493159541235801257896854698701254931595412358012578968546987012549315954123"
$a1=StringUpper($a)
$b1=StringUpper($b)
For $n=1 To 500
Dim $c
For $i=1 To StringLen($a1) Step 4
$a_1=StringMid($a1,$i,4)
$b_1=StringMid($b1,$i,4)
$d=StringCompare($a_1,$b_1)
If $d=0 Then
$c=$c&"0"
Else
$c=$c&"1"
EndIf
Next
Next
$dif = TimerDiff($begin)
MsgBox(0,"",$dif/1000)
这是我写的代码,循环500次对两个字符串进行比较,每4个字符为1组,相同的设置为1,不同的设置为0
我的机子4G内存 2.6双核
运行时间要8秒左右!
兄弟们有什么好的算法没! |