2016 - 2024

感恩一路有你

java怎么去除数组中重复的数 VBA中如何利用动态数组去除重复值?

浏览量:2061 时间:2021-03-12 11:55:02 作者:admin

VBA中如何利用动态数组去除重复值?

方法1

dim a(9) as integr

dim b() as integer

dim i as integer,j as integer

redim preserve b(0)

b(0)=a(0)

for i= 1 to ubound (a)

for j= 0 to ubound(b)

if a(i) = b(j) then goto net ,有相同的就跳出

next

redim preserve b(ubound(b) 1)

b(ubound(b))=a(i)

net: ,跳到这里,匹配下一个数据

next

a = b

方法2,有10个数,先找出最大的数,按照这个数定义一个数组,把对应的值写入对应的元素中,最好先设置一个默认值

dim a(9) as integer

dim i as integer,temp as integer

temp=a(0)

for i= 1 to ubound(a)

if a(i) > temp then

temp = a(i)

end if

next i

redim b(temp) as integer

for i= 0 to ubound(a)

b(a(i)) = a(i)

next

java怎么去除数组中重复的数 数组去重复的方法 java数组去重复

版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。