修改时间:2021-05-20 浏览次数:165 类型:高考模拟
序号 | 姓名 | 身份证号 | 进校时间 | 体温 | 是否来自高风险地区 |
1 | 张三 | 330621198806544412 | 2020-12-19 8:23:18 | 36.8 | 否 |
2 | 李四 | 330891200202243965 | 2020-12-25 15:25:55 | 36.9 | 否 |
… | … | … | … | … | … |
下列关于该来访人员登记信息系统的描述,错误的是( )
将考生原始成绩从高到低划分为A、B+、B、C+、C、D+、D、E共8个等级,各等级人数所占比例分别为3%、7%、16%、24%、24%、16%、7%、3%,如下表所示。
等级 |
A |
B+ |
B |
C+ |
C |
D+ |
D |
E |
比例 |
3% |
7% |
16% |
24% |
24% |
16% |
7% |
3% |
比如参加技术学考有20000人,小明卷面分90分,排名为1800名,则他在技术学科中的所处比例是9%。A占3%,B+占7%,因此B+所处的累积比例为4%-%10,可知他所处等级为B+。
编写一个VB程序计算学生某科目成绩的等级,功能如下:从数据库中读入学生学号、姓名、班级和原始成绩,并在列表框List1中显示,单击“等级划分”按钮Command1,在列表框List2中按原始成绩从高到低显示成绩与等级。等级划分时,先按原始成绩从高到低排序(如原始成绩相同,则按“班级”号从小到大排序),再根据人数比例计算切分位置确定等级。若切分位置有相同分数学生,则归为同一个等级。例如,某等级切分位置是第100位,但第101位学生的原始成绩和第100位相同,则这两名学生的赋分等级相同。程序运行界面如图a所示。
实现上述功能的VB程序如下,请回答下列问题:
Const max = 1000
Dim n As Integer '存放学生人数
Dim xh(1 To max) As String '数组xh存放学生的学籍号
Dim xm(1 To max) As String '数组xm存放学生的姓名
Dim bj(1 To max) As Integer '数组bj存放学生的班级
Dim fs(0 To max) As Single '数组fs存储学生的原始分数
Dim ffdj(0 To max) As String '数组ffdj存储学生的赋分等级
Private Sub Command1_Click()
Dim p(1 To 8) As Single, dj(1 To 8) As String
Dim i As Integer, j As Integer, pos As Integer, last As Integer
Dim st As String, it As Integer, sit As Single
‘从数据库中读入学生学号、姓名、班级和原始成绩,分别存入数组xh、xm、bj和fz中,代码略
p(1) = 0.03: p(2) = 0.07: p(3) = 0.16: p(4) = 0.24:p(5) = 0.24: p(6) = 0.16: p(7) = 0.07: p(8) = 0.03:dj(1) = "A": dj(2) = "B+": dj(3) = "B": dj(4) = "C+":dj(5) = "C": dj(6) = "D+": dj(7) = "D": dj(8) = "E"
For i = 2 To 8
'计算到该等级累计所占比例
Next i
For i = 1 To n - 1
For j = 1 To n - i
If Then
st = xh(j): xh(j) = xh(j + 1): xh(j + 1) = st
st = xm(j): xm(j) = xm(j + 1): xm(j + 1) = st
it = bj(j): bj(j) = bj(j + 1): bj(j + 1) = it
sit = fs(j): fs(j) = fs(j + 1): fs(j + 1) = sit
End If
Next j
Next i
pos = 1
For i = 1 To 8
last = '人数四舍五入取整
Do While fs(last + 1) = fs(last)
last = last + 1 '处理切分位置的同分数学生
Loop
Do While
ffdj(pos) = dj(i)
pos = pos + 1
Loop
Next i
For i = 1 To n
List2.AddItem xh(i) +" "+xm(i) +" "+Str(bj(i)) +" "+ Str(fs(i)) +" "+ ffdj(i)
Next i
End Sub
经过扫描后得到的数据结果为:
57 | 45 | 0 | 23 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | -30 | 1 | 0 | 0 | 0 | 0 | 0 |
-16 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
“57,45,0,0,0,0,23,0,-30,-16,0,0,1,0,0,0,0,…,0,0”,数据元素个数为64个。进一步经过压缩后,最终得到行程编码:“57, 1, 45, 1, 0, 4, 23, 1, 0, 1,-30, 1,-16, 1, 0, 2, 1, 1, 0, 51”,数据元素个数为20个。
Dim a(0 To 1000) As Integer '存储原矩阵数据,按行优先存储
Dim b(0 To 1000) As Integer '存储Z形扫描后数据
Dim c(0 To 1000) As Integer '存储行程编码压缩后数据
Dim n As Integer
‘矩阵导入代码略,以行优先存储在a数组中,如例子中数据存储顺序为“57,45,0,23,0,0…”
Private Sub Command2_Click()
Dim choice As Integer ' 1:向右移动 ;2:向右上移动;3向下移动 4向左下移动
Dim row As Integer, col As Integer, i As Integer, j As Integer
Dim pre As Integer, count As Integer
choice = 1: row = 0: col = 0: i = 0
Do While (row <> n - 1 Or col <> n - 1)
b(i) = a(row * n + col):i = i + 1
If choice = 1 Then
If row = 0 Then choice = 4 Else choice = 2
ElseIf choice = 2 Then
row = row - 1: col = col + 1
If Then
choice = 1
ElseIf col = n - 1 Then
choice = 3
End If
ElseIf choice = 3 Then
row = row + 1
If col = 0 Then choice = 2 Else choice = 4
ElseIf choice = 4 Then
row = row + 1: col = col - 1
If row = n - 1 Then
choice = 1
ElseIf col = 0 Then
choice = 3
End If
End If
Loop
b(i) = a(n * n - 1):j = 0: pre = b(0): count = 0
For i = 0 To n * n - 1 '输出Z形序列,并进行行程压缩
If pre = b(i) Then
count = count + 1
Else
c(j) = pre: c(j + 1) = count
pre = b(i):j = j + 2
End If
Next i
c(j) = pre: c(j + 1) = count
Text1.Text = ""
For i = 0 To j + 1
Text1.Text = Text1.Text + Str(c(i)) + ","
Next i
End Sub
试题篮