VB 二维数组找最大元素位置,要求先设第一行第一列为最大元素,option base 1 求代码
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 11:24:16
VB 二维数组找最大元素位置,要求先设第一行第一列为最大元素,option base 1 求代码
Option Base 1
Private Sub Command1_Click()
Dim a(4, 5) As Integer
Dim i As Integer
Dim j As Integer
Dim v As Integer
Dim h As Integer
Picture1.Cls
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(Rnd * 90) + 10
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
a(h, v) = a(1, 1)
For i = 1 To 4
For j = 1 To 5
If a(h, v) < a(i, j) Then a(h, v) = a(i, j): h = i: v = j
Next j
Next i
Picture1.Print "数组中最大元素为第" & h & "行" & "第" & v & "列的" & a(h, v)
End Sub
Private Sub Command2_Click()
End
End Sub
我写的会溢出
Option Base 1
Private Sub Command1_Click()
Dim a(4, 5) As Integer
Dim i As Integer
Dim j As Integer
Dim v As Integer
Dim h As Integer
Picture1.Cls
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(Rnd * 90) + 10
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
a(h, v) = a(1, 1)
For i = 1 To 4
For j = 1 To 5
If a(h, v) < a(i, j) Then a(h, v) = a(i, j): h = i: v = j
Next j
Next i
Picture1.Print "数组中最大元素为第" & h & "行" & "第" & v & "列的" & a(h, v)
End Sub
Private Sub Command2_Click()
End
End Sub
我写的会溢出
Option Base 1
Private Sub Command1_Click()
Dim a(4, 5) As Integer
Dim i As Integer
Dim j As Integer
Dim v As Integer
Dim h As Integer
Picture1.Cls
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(Rnd * 90) + 10
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
h = 1
v = 1
For i = 1 To 4
For j = 1 To 5
If a(h, v) < a(i, j) Then h = i: v = j
Next j
Next i
Picture1.Print "数组中最大元素为第" & h & "行" & "第" & v & "列的" & a(h, v)
End Sub
Private Sub Command2_Click()
End
End Sub
你的代码错在a(h, v) = a(1, 1)和a(h, v) = a(i, j),不但是多余的,而且会改变的数组a的值,造成错误.你说说,你干嘛要让a(h, v) = a(i, j)呢?你只需要记录最大元素的下标值即可,最后通过下标值就可以知道最大元素的值了啊!
Private Sub Command1_Click()
Dim a(4, 5) As Integer
Dim i As Integer
Dim j As Integer
Dim v As Integer
Dim h As Integer
Picture1.Cls
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(Rnd * 90) + 10
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
h = 1
v = 1
For i = 1 To 4
For j = 1 To 5
If a(h, v) < a(i, j) Then h = i: v = j
Next j
Next i
Picture1.Print "数组中最大元素为第" & h & "行" & "第" & v & "列的" & a(h, v)
End Sub
Private Sub Command2_Click()
End
End Sub
你的代码错在a(h, v) = a(1, 1)和a(h, v) = a(i, j),不但是多余的,而且会改变的数组a的值,造成错误.你说说,你干嘛要让a(h, v) = a(i, j)呢?你只需要记录最大元素的下标值即可,最后通过下标值就可以知道最大元素的值了啊!
VB 二维数组找最大元素位置,要求先设第一行第一列为最大元素,option base 1 求代码
【VB】由程序随机产生一个6*6的二维数组,输出数组中的最大元素,统计最大元素所在行的所有元素的乘积.
VB 输入一个3行4列的二维数组,分别求出每一行、每一列元素之和 要求
vb中 按如下定义的数组A的元素个数为?option base 1 dim a(-1 to 5 ,5)as intege
附加题:求二维数组中最大元素值及其行列号
option base 1 dim a(3,-2 to 2,4)数组a包含元素个数有 2 option base 0 d
二维数组4*4,求主对角线元素之和,并选出最大的元素(C语言)
C语言:有一个3*4的矩阵,要求编写求这个二维数组中的最大的那个元素的值,以及所在的行号和列号.
(1)VB 用随机函数产生20个两位数的整数,存于4行5列的二维数组中,并求出其中的最大元素及它的行、列坐标,将数组按行
【题目描述】 求二维数组(5行5列)中最大元素值及其行列号.
VB如何统计二维数组中相同元素的个数?
【单选题】语句Option Base 1:Dim a(3,4)定义的数组中,所包含的数组元素的个数是_____.