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

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

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

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

Private Sub Command1_Click() Dim a(14) As Integer maxi = 0 For i = 0 To 14 a(i) = Int(Rnd * 100) If a(maxi) < a(i) Then maxi = i Print a(i); Next i Print t = a(0): a(0) = a(maxi): a(maxi) = t Print "对换以后:" For i = 0 To 14...

Private Sub Command1_Click()Dim a(1 To 4, 1 To 4) As LongDim i As Long, j As LongDim x As Long, y As LongDim n As Long Randomize '初始化随机数,否则每次运行的内容相同 For i = 1 To 4 For j = 1 To 4 a(i, j) = Fix(Rnd * 100) '生成...

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

你好,程序如下: #include main() { int a[10], n, max, min, maxPos, minPos; for (n=0; n

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