<%
Dim n
dim s,t,d
n="a,a,a,b,c,d,e,r,f,d,e,g,g,g,f,a,a"
arrn=split(n,",")
arrnlen=Ubound(arrn)
dim charnew,charold,j,k
redim arrNew(arrnlen,arrnlen)
j=0
k=0
charnew=""
charold=""
for i=0 to ubound(arrn)
charnew=arrn(i)
if charnew=charold then
j=j+1
if j>maxJ then maxJ=j
else
j=1
k=k+1
end if
arrNew(j,k)=charnew
charold=charnew
next
maxK=k
response.write "原字符串:"&n&"<br>"
response.write "转换后字符串:<br>"
for j=0 to maxJ
for k=0 to maxK
if len(arrNew(j,k))>0 then
response.write arrNew(j,k)&" "
else
response.write " "
end if
next
response.write "<br>"
next
%>
<%
dim j
dim a1,a2,a3,a4,a5
j=1
function a(b)
m = split (b,",")
for i=0 to Ubound(m)-1
if m(i)= m(i+1) then
if j=6 then
j=1
end if
select case j
case 1
a1=a1+m(i) &","
case 2
a2=a2+m(i)&","
case 3
a3=a3+m(i)&","
case 4
a4=a4+m(i)&","
case 5
a5=a5+m(i)&","
end select
j = j+1
else
select case j
case 1
a1=a1+m(i)&","
case 2
a2=a2+m(i)&","
case 3
a3=a3+m(i)&","
case 4
a4=a4+m(i)&","
case 5
a5=a5+m(i)&","
end select
j=1
end if
next
end function
a("a,a,a,a,a,a,a,a,a,b,b,c,d,d,e,e,e,f,f,g,g,g,")
response.write a1 &"<br>"
response.write a2 &"<br>"
response.write a3 &"<br>"
response.write a4 &"<br>"
response.write a5 &"<br>"
m1 = split (a1,",")
m2 = split (a2,",")
response.write replace(a1,",","") &"<br>"
g=0
for i = 0 to Ubound(m1)-1
g=0
for j = 0 to Ubound(m2)-1
if m1(i)=m2(j) then
g = 1
end if
next
if g=1 then
response.write m1(i)
else
response.write "-"
end if
next
response.write "<br>"
m3 = split (a3,",")
g=0
for i = 0 to Ubound(m1)-1
g=0
for j = 0 to Ubound(m3)-1
if m1(i)=m3(j) then
g = 1
end if
next
if g=1 then
response.write m1(i)
else
response.write "-"
end if
next
response.write "<br>"
m4 = split (a4,",")
g=0
for i = 0 to Ubound(m1)-1
g=0
for j = 0 to Ubound(m4)-1
if m1(i)=m4(j) then
g = 1
end if
next
if g=1 then
response.write m1(i)
else
response.write "-"
end if
next
response.write "<br>"
m5 = split (a5,",")
g=0
for i = 0 to Ubound(m1)-1
g=0
for j = 0 to Ubound(m5)-1
if m1(i)=m5(j) then
g = 1
end if
next
if g=1 then
response.write m1(i)
else
response.write "-"
end if
next
<%'更正:
function a(byval b)
aa=""
m = split (b,",")
for i=0 to Ubound(m)-1
if m(i)=m(i+1) then
aa=aa+m(i)&","
else
If i>0 Then
j=asc(m(i))-asc(m(i-1))
If j>1 Then
For k=1 to j-1
response.write "-"
Next
End If
End If
response.write m(i)
end if
next
response.write "<br>"
if aa<>"" then
a(aa)
end if
end function
a("a,a,a,b,c,d,d,e,e,e,f,f,g,g,")
%>
有一点不明白,重复的留作下次再排,怎么会有超过2次甚至达到5次的时候呢?请把最终结果例举出来看看?
for i = 0 to ubound(tmp)-1
j=0:a=0
do while instr(c(j),tmp(i))>0
j=j+1
if j>=ubound(c) then a=1:exit do
loop
if a=1 then
'redim arr(j)
response.end
end if
c(j)=c(j)&" "&tmp(i)
next
for i=0 to ubound(c)
response.write c(i)&"<br>"
if c(i)&" "=" " then exit for
next
%>