首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

查寻相同和不同的字符串

2013-09-05 
查找相同和不同的字符串比如有一个字符串:a2,4,1,4,0,3,2查找并输出:相同的有:2,4不相同的有:1,0,3本人

查找相同和不同的字符串
比如有一个字符串:
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)
%>

热点排行