vb编程题 数组的最大值及其下标
1个回答
2014-06-07
展开全部
dim A(1 to 10) as integer,i as integer,n as integer,max as integer
randomize
for i=1 to 10
a(i)=int(rnd()*100) '给数组赋值
next i
max=a(1)
n=1
for i=1 to 10
if a(i)>max then
max=a(i)
n=i
end if
next i
print "最大值:";max;"下标:";n
randomize
for i=1 to 10
a(i)=int(rnd()*100) '给数组赋值
next i
max=a(1)
n=1
for i=1 to 10
if a(i)>max then
max=a(i)
n=i
end if
next i
print "最大值:";max;"下标:";n
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询