[vb]随机产生20个学生的成绩,统计各分数段人数。
答案:1 悬赏:70 手机版
解决时间 2021-01-17 04:03
- 提问者网友:聂風
- 2021-01-16 04:44
[vb]随机产生20个学生的成绩,统计各分数段人数。
最佳答案
- 五星知识达人网友:洎扰庸人
- 2021-01-16 05:48
Option Explicit
Dim d(1 To 20) As Integer
Private Sub Command1_Click()
Dim i As Integer
Picture1.Cls
For i = 1 To 20
d(i) = Int(Rnd() * 100) + 1
Picture1.Print Format(d(i), " 0");
If i Mod 4 = 0 Then Picture1.Print
Next i
End Sub
Private Sub Command2_Click()
Dim b(5) As Integer
Dim i As Integer
Picture2.Cls
For i = 1 To 20
Select Case d(i)
Case 0 To 59
b(1) = b(1) + 1
Case 60 To 69
b(2) = b(2) + 1
Case 70 To 79
b(3) = b(3) + 1
Case 80 To 89
b(4) = b(4) + 1
Case 90 To 100
b(5) = b(5) + 1
End Select
Next
Picture2.Print "0~59:"; b(1); "个"
Picture2.Print "60~79:"; b(2); "个"
Picture2.Print "70~89:"; b(3); "个"
Picture2.Print "80~99:"; b(4); "个"
Picture2.Print "90~100:"; b(5); "个"
End Sub
Private Sub Form_Load()
Command1.Caption = "产生并显示数据"
Command2.Caption = "统计分数段人数"
End Sub
Dim d(1 To 20) As Integer
Private Sub Command1_Click()
Dim i As Integer
Picture1.Cls
For i = 1 To 20
d(i) = Int(Rnd() * 100) + 1
Picture1.Print Format(d(i), " 0");
If i Mod 4 = 0 Then Picture1.Print
Next i
End Sub
Private Sub Command2_Click()
Dim b(5) As Integer
Dim i As Integer
Picture2.Cls
For i = 1 To 20
Select Case d(i)
Case 0 To 59
b(1) = b(1) + 1
Case 60 To 69
b(2) = b(2) + 1
Case 70 To 79
b(3) = b(3) + 1
Case 80 To 89
b(4) = b(4) + 1
Case 90 To 100
b(5) = b(5) + 1
End Select
Next
Picture2.Print "0~59:"; b(1); "个"
Picture2.Print "60~79:"; b(2); "个"
Picture2.Print "70~89:"; b(3); "个"
Picture2.Print "80~99:"; b(4); "个"
Picture2.Print "90~100:"; b(5); "个"
End Sub
Private Sub Form_Load()
Command1.Caption = "产生并显示数据"
Command2.Caption = "统计分数段人数"
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯