例如2个数组:
a={1,2,3,4,5,6}
b={2,4,5,7,8,9}
怎么样求得
c={7,8,9}
我的思路是先算的temp=a与b,再算的c= b 或 temp。
用的是循环做的,需要2次双循环。
有没有效率更高的方法实现???
求教
a={1,2,3,4,5,6}
b={2,4,5,7,8,9}
怎么样求得
c={7,8,9}
我的思路是先算的temp=a与b,再算的c= b 或 temp。
用的是循环做的,需要2次双循环。
有没有效率更高的方法实现???
求教
function CheckDifferent(var LName, LTime, RName, RTime: TStrings): TStrings;
var
i, j, k, l, m: integer;
SameFile: Tstrings;
begin
SameFile := TstringList.Create;
for i := 0 to RName.Count - 1 do
begin
for j := 0 to LName.Count - 1 do
begin
if RName[i] = LName[j] then
if RTime[i] <= LTime[j] then
SameFile.Add(RName[i]);
end;
end;
result := RName;
m := result.Count;
for k := 0 to SameFile.Count - 1 do
begin
for l := 0 to m - 1 do
begin
if SameFile[k] = result[l] then
begin
result.Delete(l);
m := m - 1;
break;
end;
end;
end;
SameFile.Free;end;