有两个集合A(1,8,9,10,11,12,18,25,4,7,5)
集合B(100,200,300,400,500,600,700,800,900,1000,1100)
如何在A集合中找到最大值是25时,能在B集合中自动找到对应的第8个值为800,因为A集合中的值是变化的,两个集合长度一样,是对应关系的,B集合是回定的,请教如何解决 ?
[此贴子已经被作者于2009-9-17 14:09:03编辑过]
找到A集合中最大的值后,如何返回最大值对应的索引值?
这样才能确定B集合中索引值对应的数值。
dim n as integer
dim bg as integer
dim a as string ="1,8,9,10,11,12,18,25,4,7,5"
dim aa as string ="100,200,300,400,500,600,700,800,900,1000,1100"
for i as integer = 0 to a.split(",").length -1
if a.split(",")(i) > bg then
bg = a.split(",")(i)
n=i
end if
next
output.show(aa.split(",")(n)) '结果显示:800
[此贴子已经被作者于2009-9-17 14:28:05编辑过]
谢谢4楼,可以实现了。
有没有对集合进行这样操作的更简单的方法呢?
集合更加简单
Dim v As integer = lst1(0)
Dim m As Integer
For i As integr = 1 To Lst1.Count -1
If Lst1(0)> v Then
m = i
v = lst1(i)
End If
Next
Output.Show(lst2(m))
[此贴子已经被作者于2009-9-17 15:39:55编辑过]