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

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

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

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(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 Form_Click()Dim a(10), max, i, jmax = -1For i = 1 To 10 a(i) = Int(Rnd * 100) Print a(i); If max < a(i) Then max = a(i): j = i ElseIf max = a(i) Then j = j & " " & i End IfNextPrintPrint "最大数是"; maxPrint "下标是...

窗体添加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...

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) '生成...

Dim a(10) As DoubleFor i = 0 To 9 a((i + 1) Mod 10) = 0Next i 最好的方法是: Dim a(10) As DoubleFor i = 0 To 9 a(i) = 0Next i

是你数组维数决定的 你定义数组维数为10 那么下标为0-9 最大下标9 你定义数组维数为20 那么下标为0-19 最大下标19

你好,程序如下: #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