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

'设数组为ara=ubound(ar)'数组的最大下标b=Lbound(ar)'数组的最小下标

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

窗体添加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 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 "下标是...

Private Sub Command1_Click() Cls Dim a(1 To 10) As Integer Dim xb As Integer, min As Integer For i = 1 To UBound(a) a(i) = Val(InputBox("请你输入第" & i & "个数", , "1")) Print a(i); Next i Print xb = 1: min = a(1) For i = 2 To...

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

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;“个元素"

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

我的头都想大了啊,,,,快给我分吧!!我试过了,运行得起。。。。 Dim a(1 To 5, 1 To 6), m!, n!, max!, flag!, pos! For m = 1 To 5 For n = 1 To 6 a(m, n) = Int(Rnd * 100) Print a(m, n); Next Print Next max = a(1, 1) flag = 0 pos ...

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