又来救命了,求去重函数!!(已解决)
现有两个字符串,要求找到相重的字符并去掉重复的.我下面的代码只能找到相重的只能去掉一个,哪里有错了!?!?!<%
f1="01 06 11 16 21 26 31"
t="31 32 33 11 01"
a= kill(f1,t)
response.write a
'去重函数
Function kill(strurl,strurl2)
Dim charstr
charstr=strurl & " " & strurl2
charstr=trim(charstr)
Dim newstr
newstr=Split(charstr," ")
max=UBound(newstr)
Dim i,j,flag
For i=0 To max-1
flag=newstr(i)
For j=i+1 To max-1
If newstr(j)=flag And flag<>"" Then
newstr(j)=""
End If
Next
If newstr(i)<>"" Then
strurlxx=strurlxx & " " & newstr(i)&" "
End If
Next
kill=strurlxx
End Function
%>
=========解决代码!!感觉脑子真的是越来越不会拐弯了!!======
<%
t="01 06 11 16 21 26 31"
M1="31 32 33 11 01"
a=split(t," ")
a2=split(M1," ")
a3=""
for j=0 to ubound(a)
mark=false
for j2=0 to ubound(a2)
if a(j)=a2(j2) then
mark=true
end if
next
if mark=false then
a3=a3 & " " & a(j)
end if
next
response.write a3
%>
[[it] 本帖最后由 sass2008 于 2008-5-28 14:02 编辑 [/it]]
[[it] 本帖最后由 sass2008 于 2008-5-28 14:10 编辑 [/it]]