
vb,编写过程求一维数组中的最大值及其在数组中的位置(最好能把程序写下来)
2个回答
展开全部
如果有几个最大值咋办?
dim iTest(n) as integer
dim iplace(n) as integer
dim max as integer
dim i as integer
dim j as integer
for i= 0 to n-1
if iTest(i)>iTest(i+1) then
max = iTest(i)
else
max = iTest(i+1)
end if
next
for i= 0 to n
if iTest(i)=max then
iplace(j) = i
end if
j=j+1
next
最大值:max
位置:iplace()
dim iTest(n) as integer
dim iplace(n) as integer
dim max as integer
dim i as integer
dim j as integer
for i= 0 to n-1
if iTest(i)>iTest(i+1) then
max = iTest(i)
else
max = iTest(i+1)
end if
next
for i= 0 to n
if iTest(i)=max then
iplace(j) = i
end if
j=j+1
next
最大值:max
位置:iplace()
追问
输出要怎么输出呢?能把窗体截图发一下吗
追答
Linux系统,我手打的。。。
for i = 0 to j
打印: iplace(i) //VB打印忘了。。。
next
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询