修改时间:2021-05-20 浏览次数:153 类型:高考模拟
例如:字符串“2021xuankao", 去重为“201xuanko".
Dim c(0 To 35) As Integer
s = Text1.Text: res =
For i=1 To Len(s)
ch=Mid(s,i,1)
If ch>="0" And ch<="9" Then
k = Val(ch) + 26
Else
End If
If c(k)=1 Then res=res+ch
Next i
Text2.Text = res
上述程序段中方框处可选语句为:
①k = Asc(ch) - Asc("a") ②k = Ase(ch) - Ase("A") ③e(k) = c(k) + 1 ④c(k) = 1 ⑤If k =0 Thenk=k+ 32 ⑥If k>= 32 Then k=k-32
则①②③处语句依次可为( )
For i=8 To 2 Step-1
For j=i-2 To 1 Step -2
If a(j)<a(i) And i Mod 2=1 Then
t=a(j):a(j)=a(i):a(i)=t
ElseIf a(j)>a(i) And i Mod 2=0 Then
t=a(j):a(j)=a(i):a(i)=t
End If
Next j
Next i
数组元素a(1)到a(8)的值依次为20、15、62、26、74、64、 20、32,执行该程序段后,数组元素的值依次是:( )
例如:42、50、14、16、22、10、34、10、12、38这10个数中,最大的d为50,50=12+16+22。请回答下列问题:
Dim a(1 To 20) As Integer
Const n = 10
Private Sub Command1_ Click)
Dim i As Integer
Randoni ze
For i=1Ton
a(i) =
Text1.Text = Text1. Text + Str(a(i))
Next i
End Sub
Private Sub Command2_ Click ()
Dim i As Integer, j As Integer,t As Integer
Dim left As Integer, right As Integer
Dim ans As Integer, flag As Boolean
flag = True
'对数组a进行升序排序,代码略
i=n
Do While i >= 1 And flag
j=i-1
Do While j >= 1 And flag
left = 1
right = j- 1
Do While
If ans > a(left) + a(right) Then
left=left+1
ElseIf ans < a(left) + a(right) Then
right = right-1
Else
Text2. Text = Str(a(i))
flag = False
End If
Loop
j=j-i
Loop
Loop
If flag Then
Text2. Text ='no solution'
End If
End Sub
划分赋分等级:将考生每门选考科目的原始成绩从高到低划分为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% |
转换赋分成绩: 将A至E等级内的考生原始成绩,依照等比例转换法则,分别转换到91-100、81-90、71-80、61-70、51-60、 41-50、31-40、21-30八个分数区间,得到考生的赋分成绩,如图a所示。
转换公式如下: t=t2+(s-s2)*(t1-t2)/(s1-s2), 其中t表示转化后的赋分成绩,t1 表示该档最高转化分,t2 表示该档最低转化分,s表示原始分,s1 表示该档最高原始分,s2表示该档最低原始分。
比如选择物理的学生有20000人,小明物理卷面分90分,排名为1800名,则他在物理学科中的比例是9%。按照赋分等级表可知他所处等级为B+。若原始分4%-10%区间的最高分为94,最低分为88,B+区间分数为81-90分。小明转化后的赋分成绩为81+ (90-88)* (90-81)/(94-88)=84分。
编写一个VB程序计算某校学生某科目成绩的赋分,功能如下:从数据库中读入学生学号、姓名、班级和原始成绩,并在列表框List1中显示,单击“赋分”按钮Command1,在列表框List2中按原始成绩从高到低显示赋分等级和赋分成绩。赋分时,先按原始成绩从高到低排序,再根据人数比例计算切分位置,最后对落入同一等级的学生进行赋分。若切分位置有相同分数学生,则归为同一个等级。例如,某等级切分位置是第100位,但第101位学生的原始成绩和第100位相同,则这两名学生的赋分等级相同。程序运行界面如图b所示。
实现上述功能的VB程序如下,请回答下列问题:
Const max = 1000
Dim n As Integer '存放学生人数
Dim xh(1 To max) As String, xm(1 To max) As String
Dim bj(1 To max) As Integer, fs(0 To max) As Single
Dim ffcj(1 To max) As Integer '数组ffdj存储学生的赋分等级
Dim ffdj(O To max) As String '数组ffcj存储学生的赋分成绩
Private Sub Form_ Load()
Dim i As Integer, km As String
Dim conn As New ADODB. Connect ion
Dim rs As New ADODB. Recordset
Conn.ConnectionString =“prov ider-microsoft.ace.oledb.12.0;data source=” +App. Path + “\s tudent. accdb”
conn. Open
Set rs. ActiveConnection = conn
Rs. Open' 'select * from stu_ info"
‘本过程其它代码从数据库中读入学生学号、姓名、班级和原始成绩存储到数组xh、xm、bj和fs中,并在List1中显示。学生数存储在变量n中。
Loop
End Sub
Private Sub Command1_ Click()
Dim q(1 To max) As Integer, p(1 To 8) As Single, dj(1 To 8) As String
Dimi As Integer,j As Integer, t As Integer, pos As Integer, last As Integer
Dim t1 As Integer, t2 As Integer, s1 As Single, s2 As Single
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 ‘计算到该等级累计所占比例
p(i) =
Next i
For i=1 To n
q(i) = i
Next i
For i=1 To n- 1
For j=n To i+1 Step-1
If fs(q(j)) > fs(q(j - 1)) Then
t=q(j):q(j)=q(j-1):q(j-1)=t
End If
Next j
Next i
pos=1
t1=100:t2=91
For i =1 To 8
last=Int(n*p(i)+0.5)
Do While
last=last+1 ‘处理切分位置的同分数学生
Loop
s1 = fs(q(pos)): s2 = fs(q(last))
Do While pos <= last
ffcj(q(pos)) = t2 + (fs(q(pos)) - s2) / (s1 - s2) * (t1 - t2)
pos=pos+1
Loop
t1 = t1 -10:t2=t2- 10
Next i
For i=1 To n
List2. AddItem xh(q(i)) + xm(q(i)) + Str(bj(q(i))) + dj(ffdj(q(i))) +Str (ffcj(q(i)))
Nexti
End Sub
试题篮