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...

Option Explicit Dim A(4, 4) As Integer Private Sub command1_click() Dim i As Integer, j As Integer Picture1.Cls Randomize For i = 0 To 4 For j = 0 To 4 A(i, j) = Int(Rnd * 90 + 10) Picture1.Print A(i, j); Next j Picture1.Print ...

Dim d() As Integer Dim i As Integer Dim MyMax As Integer Dim n As Integer n = Val(InputBox("输入n!")) ReDim d(n) As Integer For i = 1 To n d(i) = Val(InputBox("输入第" & i & "个数!")) Next i MyMax = d(1) For i = 2 To n If d(i)...

下面的代码能正确执行,已经调试通过: 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...

这个下标通常是指数组的编号,下标越界是指你给出的编号超出了这个数组的编号范围。 打个比方:你们班总共56个同学,那么从1到56就是你们班学生的编号范围(或下标),如果某人想找你们班的“第64号”同学,那肯定是找不到的,这就是“下标越界‘’。...

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