請問一下,動態一維數組中如何判斷數組中是否存在相同的值呢?
比如說動態數組A()
A(1)="A" A(2)="B" A(3)="A"
動態數組B()
B(1)=1 B(2)=2 B(3)=3
最後輸出的是 A 4 B 2
就是A(1)+A(3) 相同的數組B()相加輸出,不相同的直接輸出B()對應的值
a=split("A,B,A",",")
b=split("1,2,3",",")
for i = 0 to ubound(a)
for j = i+1 to ubound(a)
if a(i)<>"" and a(i)=a(j) then
a(j)=""
b(i) =cint( b(i)) + cint(b(j))
b(j)=0
exit for
end if
next
next
for i =0 to ubound(a)
if a(i) <> "" then
msgbox a(i) & " " & b(i)
end if
next