VB输入学生成绩
答案:2 悬赏:70 手机版
解决时间 2021-02-18 09:41
- 提问者网友:書生途
- 2021-02-17 16:42
VB输入学生成绩
最佳答案
- 五星知识达人网友:风格不统一
- 2021-02-17 17:18
Private Sub Main()
Dim Scores(1 To 10) As Single
Call InputScore(Scores)
Call PrintScore(Scores)
Call AboveAverage(Scores)
Call ScoreSort(Scores)
Call PrintScore(Scores)
Call FindMaxMin(Scores)
End Sub
Private Sub InputScore(sngScores() As Single)
Dim i As Single
For i = LBound(sngScores) To UBound(sngScores)
sngScores(i) = InputBox("请输入第" & i & "名学生高考成绩:", "高考成绩管理系统", 600)
Next i
End Sub
Private Sub PrintScore(sngScores() As Single)
Dim i As Integer
Load Form1
Form1.Show
For i = LBound(sngScores) To UBound(sngScores)
Form1.Print sngScores(i);
Next i
Form1.Print
End Sub
Private Sub ScoreSort(sngScores() As Single)
Dim i As Integer, j As Integer, t As Single
For i = LBound(sngScores) To UBound(sngScores) - 1
For j = i + 1 To UBound(sngScores)
If sngScores(j) > sngScores(i) Then
t = sngScores(i)
sngScores(i) = sngScores(j)
sngScores(j) = t
End If
Next j
Next i
End Sub
Private Sub AboveAverage(sngScores() As Single)
Dim i As Integer, k As Integer, sngSum As Single, sngAverage As Single
For i = LBound(sngScores) To UBound(sngScores)
sngSum = sngSum + sngScores(i)
Next i
sngAverage = sngSum / UBound(sngScores)
For i = LBound(sngScores) To UBound(sngScores)
If sngScores(i) > sngAverage Then
k = k + 1
End If
Next i
Form1.Print "平均值为:"; sngAverage,
Form1.Print "高于平均值的人数为:"; k
End Sub
Private Sub FindMaxMin(sngScores() As Single)
Dim i As Integer, sngMax As Single, sngMin As Single
sngMax = sngScores(LBound(sngScores))
sngMin = sngScores(LBound(sngScores))
For i = LBound(sngScores) + 1 To UBound(sngScores)
If sngScores(i) > sngMax Then sngMax = sngScores(i)
If sngScores(i) < sngMin Then sngMin = sngScores(i)
Next i
Form1.Print "最高分为:"; sngMax, "最低分为:"; sngMin
End Sub
Dim Scores(1 To 10) As Single
Call InputScore(Scores)
Call PrintScore(Scores)
Call AboveAverage(Scores)
Call ScoreSort(Scores)
Call PrintScore(Scores)
Call FindMaxMin(Scores)
End Sub
Private Sub InputScore(sngScores() As Single)
Dim i As Single
For i = LBound(sngScores) To UBound(sngScores)
sngScores(i) = InputBox("请输入第" & i & "名学生高考成绩:", "高考成绩管理系统", 600)
Next i
End Sub
Private Sub PrintScore(sngScores() As Single)
Dim i As Integer
Load Form1
Form1.Show
For i = LBound(sngScores) To UBound(sngScores)
Form1.Print sngScores(i);
Next i
Form1.Print
End Sub
Private Sub ScoreSort(sngScores() As Single)
Dim i As Integer, j As Integer, t As Single
For i = LBound(sngScores) To UBound(sngScores) - 1
For j = i + 1 To UBound(sngScores)
If sngScores(j) > sngScores(i) Then
t = sngScores(i)
sngScores(i) = sngScores(j)
sngScores(j) = t
End If
Next j
Next i
End Sub
Private Sub AboveAverage(sngScores() As Single)
Dim i As Integer, k As Integer, sngSum As Single, sngAverage As Single
For i = LBound(sngScores) To UBound(sngScores)
sngSum = sngSum + sngScores(i)
Next i
sngAverage = sngSum / UBound(sngScores)
For i = LBound(sngScores) To UBound(sngScores)
If sngScores(i) > sngAverage Then
k = k + 1
End If
Next i
Form1.Print "平均值为:"; sngAverage,
Form1.Print "高于平均值的人数为:"; k
End Sub
Private Sub FindMaxMin(sngScores() As Single)
Dim i As Integer, sngMax As Single, sngMin As Single
sngMax = sngScores(LBound(sngScores))
sngMin = sngScores(LBound(sngScores))
For i = LBound(sngScores) + 1 To UBound(sngScores)
If sngScores(i) > sngMax Then sngMax = sngScores(i)
If sngScores(i) < sngMin Then sngMin = sngScores(i)
Next i
Form1.Print "最高分为:"; sngMax, "最低分为:"; sngMin
End Sub
全部回答
- 1楼网友:往事埋风中
- 2021-02-17 17:58
输入学生成绩 然后做什么呢
统计最高分 最低分?
统计最高分 最低分?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯