回复 14# netegg
谢谢蛋大!
这是我晚交的功课, 主要利用数组来处理.
#include <array.au3>
Local $Str = _
'12345 2' & @CRLF & _
'12344 1' & @CRLF & _
'22110 2' & @CRLF & _
'12005 1' & @CRLF & _
'5512 2' & @CRLF & _
'22110 5' & @CRLF & _
'12344 3'
MsgBox(0, '原字符串', $Str)
Local $aSR = StringRegExp($Str, '(\d+) (\d+)', 3)
Local $sOut[1], $totle[1]
For $i = 0 To UBound($aSR) - 1 Step 2
$index = _ArraySearch($sOut, $aSR[$i])
If @error Then
_ArrayAdd($sOut, $aSR[$i])
_ArrayAdd($totle, $aSR[$i+1])
ContinueLoop
EndIf
$totle[$index] += $aSR[$i+1]
Next
$Str = ''
For $i = 1 To UBound($sOut) -1
$Str &= $sOut[$i] & @TAB & $totle[$i] & @CRLF
Next
MsgBox(0, '合并计算', $Str)
|