有10名学生的英语和计算机成绩,编写VB程序求出英语和计算机最高分成绩的姓名
这是我的代码,最主要是后半部分求名字解决不了,望大神相助~OptionExplicitPrivateSubCommand1_Click(IndexAsInteger)Co...
这是我的代码,最主要是后半部分求名字解决不了,望大神相助~
Option Explicit
Private Sub Command1_Click(Index As Integer)
Const count = 10
Dim stu(1 To 10, 1 To 3)
Dim i, j, max, min As Integer
Dim m, n As Integer
For i = 1 To count
stu(i, 1) = InputBox("请输入第" & i & "个同学的名字")
For j = 1 To 2
stu(i, j + 1) = Val(InputBox("请输入第" & i & "个同学的第" & j & "门课成绩"))
Next j
Next i
Print "以下为学生的成绩信息:"
For i = 1 To count
For j = 1 To 3
Print stu(i, j);
Next j
Print
Next i
max = stu(1, 2)
If stu(i, 2) > stu(1, 2) Then
max = stu(i, 2)
End If
m = i
Print "英语最高分是:" & stu(m, 1)
max = stu(1, 3)
If stu(i, 3) > stu(1, 3) Then
max = stu(i, 3)
End If
n = i
Print "计算机最高分是:" & stu(n, 1)
End Sub 展开
Option Explicit
Private Sub Command1_Click(Index As Integer)
Const count = 10
Dim stu(1 To 10, 1 To 3)
Dim i, j, max, min As Integer
Dim m, n As Integer
For i = 1 To count
stu(i, 1) = InputBox("请输入第" & i & "个同学的名字")
For j = 1 To 2
stu(i, j + 1) = Val(InputBox("请输入第" & i & "个同学的第" & j & "门课成绩"))
Next j
Next i
Print "以下为学生的成绩信息:"
For i = 1 To count
For j = 1 To 3
Print stu(i, j);
Next j
Next i
max = stu(1, 2)
If stu(i, 2) > stu(1, 2) Then
max = stu(i, 2)
End If
m = i
Print "英语最高分是:" & stu(m, 1)
max = stu(1, 3)
If stu(i, 3) > stu(1, 3) Then
max = stu(i, 3)
End If
n = i
Print "计算机最高分是:" & stu(n, 1)
End Sub 展开
2个回答
展开全部
刚才的那位,无法处理最高分并列情况,因此需要改进如下:
Option Explicit
Private Sub Command1_Click()
Const count = 10
Dim stu(1 To 10, 1 To 3)
Dim i, j, max, min As Integer
Dim maxName As String
Dim m, n As Integer
For i = 1 To count
stu(i, 1) = InputBox("请输入第" & i & "个同学的名字")
For j = 1 To 2
stu(i, j + 1) = Val(InputBox("请输入第" & i & "个同学的第" & j & "门课成绩"))
Next j
Next i
Print "以下为学生的成绩信息:"
For i = 1 To count
For j = 1 To 3
Print stu(i, j);
Next j
Next i
For i = 1 To count
If stu(i, 2) >= stu(1, 2) Then max = stu(i, 2) '选出最高分
Next
For i = 1 To count
If stu(i, 2) = max Then Print "英语最高分是:"; stu(i, 1), stu(i, 2) '如果是最高分,就打印
Next
For i = 1 To count
If stu(i, 3) >= stu(1, 3) Then max = stu(i, 3)
Next
For i = 1 To count
If stu(i, 3) = max Then Print "计算机最高分是:"; stu(i, 1), stu(i, 3)
Next
End Sub
展开全部
Option Explicit
Private Sub Command1_Click()
Const count = 10
Dim stu(1 To 10, 1 To 3)
Dim i, j, max, min As Integer
Dim m, n As Integer
For i = 1 To count
stu(i, 1) = InputBox("请输入第" & i & "个同学的名字")
For j = 1 To 2
stu(i, j + 1) = Val(InputBox("请输入第" & i & "个同学的第" & j & "门课成绩"))
Next j
Next i
Print "以下为学生的成绩信息:"
For i = 1 To count
For j = 1 To 3
Print stu(i, j);
Next j
Print
Next i
max = stu(1, 2)
m = 1
For i = 2 To count
If stu(i, 2) > max Then
max = stu(i, 2)
m = i
End If
Next i
Print "英语最高分是:" & stu(m, 1) & " " & stu(m, 2)
max = stu(1, 3)
n = 1
For i = 2 To count
If stu(i, 3) > max Then
max = stu(i, 3)
n = i
End If
Next i
Print "计算机最高分是:" & stu(n, 1) & " " & stu(n, 3)
End Sub
Private Sub Command1_Click()
Const count = 10
Dim stu(1 To 10, 1 To 3)
Dim i, j, max, min As Integer
Dim m, n As Integer
For i = 1 To count
stu(i, 1) = InputBox("请输入第" & i & "个同学的名字")
For j = 1 To 2
stu(i, j + 1) = Val(InputBox("请输入第" & i & "个同学的第" & j & "门课成绩"))
Next j
Next i
Print "以下为学生的成绩信息:"
For i = 1 To count
For j = 1 To 3
Print stu(i, j);
Next j
Next i
max = stu(1, 2)
m = 1
For i = 2 To count
If stu(i, 2) > max Then
max = stu(i, 2)
m = i
End If
Next i
Print "英语最高分是:" & stu(m, 1) & " " & stu(m, 2)
max = stu(1, 3)
n = 1
For i = 2 To count
If stu(i, 3) > max Then
max = stu(i, 3)
n = i
End If
Next i
Print "计算机最高分是:" & stu(n, 1) & " " & stu(n, 3)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询