i = 1: t = 0
Do While i <= 10
If i Mod 3 = 0 Then i = i + 2
t = t + 1
i = i + 1
Loop
执行该程序段后,变量i和t的值分别为( )
i=6: flag =1: cnt=0
Do While i >=2 And flag=1
flag=0: cnt= cnt +1
For j =
If a(j)>a(j-1)Then
k=a(j):a(j)=a(j-1):a(j-1)=k
flag= 1
End If
Next j
i=i-1
Loop
数组元素a(1)到a(6)的值依次为“79,13,93,55,29,17”,执行该程序段后,cnt的值为3,数组元素实现有序,则方框中的代码是( )
key = Int (Rnd*5)*2+ 11
i = 1: j = 8: c = 0
Do While i <= j
m = (i+j+1) \ 2
If a(m) >= key Then i = m+1 Else j = m-1
c = c+1
Loop
数组元素a(1)到a(8)的值依次为“23,21,19,18,16,15,14,11”。若该程序段执行后,下列说法错误的是( )
(计算公式:第四季度销量占全年比重%=第四季度累计销量/全年累计销量×100)
图b
图b
则在测试影片时,下列说法正确的是_________(单选,填字母)
Const n = 10
Dim d(n) As Integer, c As Integer
Private Sub Form_Load()
Dim i As Integer, j As Integer, f As Boolean, s As String
Randomize
c = n
For i = 1 To n
f = False
d(i) = ① ' 随机生成个位数为“9”的两位数
For j = 1 To i - 1
If ② Then f = True
Next j
If f Then c = c - 1
Next i
'原始数据在文本框Text1中显示。代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, m As Integer
Dim cnt As Integer,t As String, s As String
d(0) = 100
cnt = Val(Text2.Text)
If cnt > c Then
Text3.Text = "输入筛选的个数太大,请重新输入!"
Exit Sub 'Exit Sub表示退出过程
End If
For i = 1 To cnt
k = i
For j = i + 1 To n
If d(j) < d(i - 1) And ( ) Then k = j
Next j
If k <> i Then
t = d(i): d(i) = d(k): d(k) = t
End If
Next i
For i = 1 To cnt
s = s + Str(d(i)) + ","
Next i
Text3.Text = ③
End Sub
① ② ③
例如,标准答案为“ABE”,则对应得分表如下所示。
学生答案 | ABE | AB | AE | BE | A | B | E | AC | ...... |
字符串 | 11001 | 11000 | 10001 | 01001 | 10000 | 01000 | 00001 | 10100 | ...... |
十进制数(x) | 25 | 24 | 17 | 9 | 16 | 8 | 1 | 20 | ...... |
ans(x) | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 |
小温依据上述描述设计了“多选题阅卷”的VB程序,实现如下功能:在文本框Text1中输入标准答案(大写字母),先单击“初始化”按钮Command1,在数组ans中生成所有答案组合对应的分值,然后单击“阅卷”按钮Command2,从数据库中读取学生的答案并进行阅卷,在列表框List1中显示得分结果。程序运行界面如图所示。
Dim ans(0 To 31) As Integer
Private Sub Command1_Click()
Dim b(0 To 4) As Integer
Dim s As String, c As String, sum As Integer, k As Integer
'初始化数组ans和数组b,各元素的初始值均为0。代码略
s = Text1.Text:k = Len(s)
For i = 1 To k
c = Mid(s, i, 1)
b(Asc(c) - 65) = 2 ^ (69 - Asc(c))
Next i
For i = 0 To 4
If b(i) <> 0 Then
ans(b(i)) = 1
sum = ①
End If
Next i
ans(sum) = 2
'当标准答案含3个及以上选项时,学生答案选其中2个选项可得1分
i = 0
Do While k >= 3 And i <= 4
For j = i + 1 To 4
If b(i) * b(j) <> 0 Then ans(b(i) + b(j)) = 1
Next j
i = i + 1
Loop
i = 0
Do While k >= 4 And i <= 4
For j = i + 1 To 4
If b(i) * b(j) = 0 Or k = 5 Then ②
Next j
i = i + 1
Loop
'当标准答案含5个选项时,学生答案选其中4个选项可得1分。代码略
End Sub
Private Sub Command2_Click()
Dim xh(1 To 1000) As String, answer(1 To 1000) As String
'从数据库中读取学生学号和答案的数据分别存储在数组xh和answer中
'记录总数存储在变量n中,代码略
List1.Clear
For i = 1 To n
List1.AddItem xh(i) + " " + answer(i) + " " + Str(ans(f(answer(i))))
Next i
End Sub
Function f(s As String) As Integer
Dim i As Integer, x As Integer
x = 0
For i = 1 To Len(s)
x = ③
Next i
f = x
End Function
① ② ③