一道VB题,我做出来是和标准答案不同,只要第二步份.Private Sub Command2_Click()Sum = 0For i = 1 To 20Min = a(1,1)For j = 2 To 5If a(i,j) < Min ThenMin = a(i,j)End IfNext jSum = Sum + MinNext iText2.Text = Sum / 20End Sub打开代码
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 15:53:28
一道VB题,我做出来是和标准答案不同,只要第二步份.Private Sub Command2_Click()Sum = 0For i = 1 To 20Min = a(1,1)For j = 2 To 5If a(i,j) < Min ThenMin = a(i,j)End IfNext jSum = Sum + MinNext iText2.Text = Sum / 20End Sub打开代码
一道VB题,我做出来是和标准答案不同,只要第二步份.
Private Sub Command2_Click()
Sum = 0
For i = 1 To 20
Min = a(1,1)
For j = 2 To 5
If a(i,j) < Min Then
Min = a(i,j)
End If
Next j
Sum = Sum + Min
Next i
Text2.Text = Sum / 20
End Sub
打开代码编辑窗口,在指定位置编写以下代码:
参考代码:
Sum = 0
For i = 1 To 20
Min = a(1,1)
For j = 2 To 5
If Min > a(i,j) Then Min = a(i,j)
Next
Sum = Sum + Min
Next
Text2 = Sum / 20
写错了,上面是标准答案
Private Sub Command2_Click()
Sum = 0
For i = 1 To 20
Min = a(1, 1)
For j = 2 To 5
If a(i, j) < Min Then
Min = a(i, j)
End If
Next j
Sum = Sum + Min
Next i
Text2.Text = Sum / 20
End Sub
打开代码编辑窗口,在指定位置编写以下代码:
参考代码:
Sum = 0
For i = 1 To 20
Min = a(i, 1)
For j = 2 To 5
If Min > a(i, j) Then Min = a(i, j)
Next
Sum = Sum + Min
Next
Text2 = Sum / 20
一道VB题,我做出来是和标准答案不同,只要第二步份.Private Sub Command2_Click()Sum = 0For i = 1 To 20Min = a(1,1)For j = 2 To 5If a(i,j) < Min ThenMin = a(i,j)End IfNext jSum = Sum + MinNext iText2.Text = Sum / 20End Sub打开代码
Min = a(1, 1)
你这个是假设第一个元素是最小数,当i=2,也就是比较到第2行的时候,假如a(1,1)=5
但第2行最小一个数是7,也就是 If Min > a(i, j) Then Min = a(i, j)始终不成立,这样Min就取值为5,但实际上第2行最小数是7
因此应该是这样Min=a(i,1)即假设每行第一个元素是最小数