求AB两个字符串组并集(100)

A

agut

Unregistered / Unconfirmed
GUEST, unregistred user!
假如我有两个字符串组A和B。A里的内容为:strings[0]=12345strings[1]=23456strings[2]=34567strings[3]=45678strings[4]=56789……B里的内容为:strings[0]=12345strings[1]=08542strings[2]=23456A与B有一小部分相同的,我只需要把相同的部分如上面的:12345 23456保存到C.stringlist中,请问如何实现?
 
2循环就可以了。。。a.Stringsb.Strings
 
用一个循环以及indexof就行
 
是啊 ,用循环比较 有相同的就存起来 非常eazy啊
 
for I := 0 to A.Count -1 do begin if B.IndexOf(A.Strings)<> -1 then C.Add(A.Strings)
end;
 
for i := 0 to a.count-1 dobegin for j:=0 to b.count-1 do begin if a.string=b.string[j] then c.add(a.string)
end;end;
 
for I := 0 to A.Count -1 do begin if B.IndexOf(A.Strings)>=0 then C.Add(A.Strings)
end;
 
同意楼上的
 

Similar threads

回复
0
查看
665
不得闲
S
回复
0
查看
949
SUNSTONE的Delphi笔记
S
S
回复
0
查看
770
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部