blsn.net
当前位置:首页 >> vB编程题 数组的最大值及其下标 >>

vB编程题 数组的最大值及其下标

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;"下标...

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;"下标...

设数组为a(10) dim temp as integer dim j as integer for i=0 to 10 if temp

dim a(10) as integer dim max as integer,i as integer,j as integer ………… max=a(1):j=1 for i=2 to 10 if a(i)>max then max=a(i) j=i endif ?"最大值是:";max,"它是第“;j;“个元素"

Private Sub Command1_Click() Me.Cls Dim arr(10) As Single, j As Long, m As Single, n As Single m = 0 n = 100 For j = 1 To 10 arr(j) = 60 + Format(Rnd() * 39, "0") + (Rnd() * 2 \ 2) * 0.5 + (Rnd() * 2 \ 2) * 0.5 If m = arr(j) T...

窗体添加command1,然后拷贝下面代码 Dim a(4) As Integer Private Sub Command1_Click() Dim sum As Integer Dim i As Integer Dim maxItem As Integer For i = 0 To UBound(a()) If maxItem < a(i) Then maxItem = a(i) sum = sum + a(i) Next...

下面的代码能正确执行,已经调试通过: Sub xxx() Dim Sstr, Arr, Vmin, Vmax, i Sstr = InputBox("输入一些数字,用空格分开") Arr = Split(Trim(Sstr), " ") For i = LBound(Arr) To UBound(Arr) If Trim(Arr(i)) "" Then Arr(i) = Val(Arr(i)...

Private Sub Command1_Click() Dim a() As Integer m = InputBox("请输入行数m:") n = InputBox("请输入列数n:") ReDim a(m, n) For i = 1 To m For j = 1 To n a(i, j) = InputBox("请输入a(" & i & "," & j & ")") Print a(i, j); Next j Prin...

很简单 for i=0 to 5 a(i)=inputbox("输入任意数",找最值) next i max=a(0) max_j=0 for j=1 to 5 if(a(j)>max) then max=a(j) max_j=j endif next j print max max_j 这个就是的 上面的>改成

表面上看这些代码没有太大的问题,MAX函数有点小问题,就是如果参数数组下标不是从0开始时,程序可能会发生错误或不返回正确的结果

网站首页 | 网站地图
All rights reserved Powered by www.blsn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com