贴一个时间复杂度高一点点的,但不到2m
#include <Array.au3>
#include <File.au3>
Global $arrayA, $arrayB
Global $dic = ObjCreate("Scripting.Dictionary")
Global $strAinc = "", $strADiff = ""
$foutInc = FileOpen("AI.txt", 2)
$foutDiff = FileOpen("C.txt", 2)
$stime = TimerInit()
_FileReadToArray("A.txt", $arrayA)
_FileReadToArray("B.txt", $arrayB)
For $index = 1 To $arrayA[0]
$dic.Add($arrayA[$index], 1)
Next
For $index = 1 To $arrayB[0]
If($dic.Exists($arrayB[$index]))then
$strAinc &= $arrayB[$index]&@CRLF
Else
$strADiff &= $arrayB[$index]&@CRLF
EndIf
Next
FileWrite($foutInc, $strAinc)
FileWrite($foutDiff, $strADiff)
FileClose($foutInc)
FileClose($foutDiff)
$etime = TimerDiff($stime)
MsgBox(64, "耗时", $etime)
|