vb编程,如何在数组中找到最大最小值?

来源:百度知道 编辑:UC知道 时间:2024/05/22 00:03:53
vb编程,如何在数组中找到最大最小值,要返回其位置

dim str as string
dim str1 as new str
dim max,i,n as integer
max=0
n=0 'n用于记录位置
'随机分配两位数的数组
for i=0 to str1.length
str1[i]=Sint(rnd()*10+90)
end for
'对数组进行排序
for i=0 to str1.length
if max<str1[i] then
max=str1[i]
n=i
end if
end for

int max=0;
for(int i=0;i<s.Length;i++)
{
max=s[i]>max?s[i]:max;
}