asp求统计数组里重复元素个数,并求得对应位置的和
a=1|b=1,a=1|b=1,a=1|b=3要求结果a=1b=5(即1+1+3)高分求具体代码...
a=1|b=1,a=1|b=1,a=1|b=3
要求结果
a=1
b=5(即1+1+3)
高分求具体代码 展开
要求结果
a=1
b=5(即1+1+3)
高分求具体代码 展开
1个回答
展开全部
dim ArryStr,A,B
ArryStr="a=1|b=1,a=1|b=1,a=1|b=3"
ArryStr=replace(ArryStr,",","|")''先把逗号符替换为|分隔
ArryStr=Split(ArryStr,"|")''分割为数组
For I=0 to Ubound(ArryStr)
if instr(ArryStr(I),"a=")>0 then
A=A+Split(ArryStr(I),"=")(1)
end if
if instr(ArryStr(I),"b=")>0 then
B=B+Split(ArryStr(I),"=")(1)
end if
Next
Response.write "a="&A
Response.write "<br />"
Response.write "b="&B
ArryStr="a=1|b=1,a=1|b=1,a=1|b=3"
ArryStr=replace(ArryStr,",","|")''先把逗号符替换为|分隔
ArryStr=Split(ArryStr,"|")''分割为数组
For I=0 to Ubound(ArryStr)
if instr(ArryStr(I),"a=")>0 then
A=A+Split(ArryStr(I),"=")(1)
end if
if instr(ArryStr(I),"b=")>0 then
B=B+Split(ArryStr(I),"=")(1)
end if
Next
Response.write "a="&A
Response.write "<br />"
Response.write "b="&B
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询