日期:2014-05-16  浏览次数:20760 次

查找相同和不同的字符串
比如有一个字符串:
a="2,4,1,4,0,3,2"

查找并输出:
相同的有:
2,4
不相同的有:
1,0,3

本人实在太菜了,想了半天没有想出怎么循环

------解决方案--------------------
一个冒泡不就解决了吗
------解决方案--------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Option Explicit
Response.Charset="UTF-8"

Dim a,i,n,arr,list,repeat,sole,temp,s_tmep,str,l
a="2,4,1,4,0,3,2"
arr=Split(a,",")
list="
------解决方案--------------------
"
For i=0 To UBound(arr)
    If instr(list,"
------解决方案--------------------
"&arr(i)&"
------解决方案--------------------
")=0 Then
temp=Split(a,arr(i))
        If UBound(temp)>1 Then
            repeat=repeat&","&arr(i)
l=0
str=""
For n=0 To UBound(temp)-1
l=l+Len(Replace(temp(n),",",""))
If n>0 Then l=l+1
str=str&"和第"&l&"位的"&arr(i)
Next
s_tmep=s_tmep&Mid(str,2)&"相同<br />"
        Else
            sole=sole&","&arr(i)
        End If
    list=list&arr(i)&"
------解决方案--------------------
"
    End If
Next
Response.write "相同的有:"&Mid(repeat,2)&"<br />"
Response.write s_tmep&"<br />"
Response.write "不相同的有:"&Mid(sole,2)
%>