七喜雪碧什么梗:关于循环的问题

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 11:49:58
字符串"0//1//1//1//1//2//2//3//4//4//5//11//"
怎么样输出0 1 2 3 4 5 11 以及它们各自的个数?
谢谢
我用的是数组 for循环
但是没有达到预期的效果
琢磨了个很久 自己出了个答案,但是有没有好的代码
mn="0//1//1//1//1//2//2//3//4//4//5//11"
a=split(mn,"//")
n=1
dim b()
redim b(ubound(a))
for i = 0 to ubound(a)
b(i)=0
' response.write a(i) &"||"
next
for i = 0 to ubound(a)-1
for j= i+1 to ubound(a)
if a(i)=a(j) then
b(i)=b(i)+1
end if
next
' response.write a(i) &"||"
next
for i = 0 to ubound(a)
if b(i)=0 then
response.write a(i) &"||"&b(i)+1&"<br>"
else
response.write a(i) &"||"&b(i)+1&"<br>"
i=I+b(i)
end if
next
恋苍天的太复杂拉,我查询的字符串是动态生成的

<script language=vbscript>
a="0//1//1//1//1//2//2//3//4//4//5//11//"
b=split(a,"//",-1,1)
dim c(20)
j=0

for i=0 to UBound(b)-1
if i=0 then
C(j)=b(i)
j=j+1
end if
if b(i+1)<>b(i) then
c(j)=b(i+1)
j=j+1

end if

next

for k=0 to 6
u=u&c(k)
next
document.write u&"<br>"
o=1
j=1
k=1
l=1
p=1
r=1
s=1
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=0 then
o=o+1
end if
next
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=1 then
j=j+1
end if
next
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=2 then
k=k+1
end if
next
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=3 then
l=l+1
end if
next
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=4 then
p=p+1
end if
next
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=5 then
r=r+1
end if
next
for i=0 to UBound(b)-1
if b(i+1)=b(i) and b(i)=11 then
s=s+1
end if
next
document.write "总共有"&o&"个0"&"<br>"
document.write "总共有"&j&"个1"&"<br>"
document.write "总共有"&k&"个2"&"<br>"
document.write "总共有"&l&"个3"&"<br>"
document.write "总共有"&p&"个4"&"<br>"
document.write "总共有"&r&"个5"&"<br>"
document.write "总共有"&s&"个11"&"<br>"
</script>

我晚饭都没吃呢!!!!你可真会出题呀!!食堂没饭了!!!赔我饭钱!!

有意思,晚上搞搞。

用什么语言?