下列说法正确的是( )
a(1) = 1: s = 0
For i = 2 To 6
s = 0
For j = 1 To i – 1
s = s + a(j)
Next j
a(i) = s + 1
Next i
执行该程序段后,a(6)的值为( )
s = Text1.Text
If Mid(s, 1, 1) = "(" Then flag = True Else flag = False
cnt = 0: sum = 0
For i = 2 To Len(s)
c = Mid(s, i, 1)
If flag = True Then
If c >= "a" And c <= "z" Then
sum = sum + 1
Else
If sum <> 0 Then cnt = cnt + 1: sum = 0
End If
End If
If c = "(" Then flag = True
If c = ")" Then flag = False
Next i
文本框Text1的内容为一串只包含小写字母、左右括号和空格的字符串“(we can) do (better) we (should (be )better)”,执行程序段后,变量cnt的值为( )
L = 1: R = n
Do While L <= R
m = (L + R) \ 2
If Then
R = m - 1
Else
L = m + 1
End If
Loop
Text1.Text =
为实现上述功能,则程序中方框处填写的代码是( )
For i = 1 To 5
k = i
For j = i + 1 To 6
If a(j) Mod 3 <= a(k) Mod 3 Then k = j
Next j
tmp = a(i): a(i) = a(k): a(k) = tmp
Next i
数组元素 a(1)~a(6)的值依次为“62,54,35,67,15,34”。执行该程序段后,a(1)~a(6)的值依次为( )
图 b
图 c
①将第30帧内容复制到第50帧
②将第50帧移动到第40帧
③在第50帧执行“插入空白关键帧”操作
④选择第40帧,创建补间动画
⑤选择第50帧,创建补间动画
编写VB程序,功能如下:在文本框Text1中输入n的值,单击“生成”按钮Command1,
生成网格和随机的挡板,并输出。然后单击“开始”按钮Command2,在文本框Text2中显示小球进入网格后的运动路径。程序中利用数组a存储网格的状态,其中“/”与“\”两种字符表示两种朝向的挡板。程序运行界面如图c所示。
图 c
请回答下列问题:
Dim n As Integer
Dim a(0 To 100) As String
Private Sub Command1_Click() '生成网格和挡板
n = Val(Text1.Text)
'生成 n*n 的网格和随机的挡板,并通过图形控件输出,代码略
End Sub
Private Sub Command2_Click()
Dim ans As String, pre As String
Dim cur As Integer
cur = 1: : ans = ""
Do While cur >= 1 And cur <= n * n
ans = ans + Str(cur) + "→"
If pre = "左" And a(cur) = "\" Or pre = "右" And a(cur) = "/" Then
cur = cur + n: pre = "上"
ElseIf Then
cur = cur - n: pre = "下"
ElseIf pre = "上" And a(cur) = "\" Or pre = "下" And a(cur) = "/" Then
If cur Mod n = 0 Then
Exit Do
Else
cur = cur + 1: pre = "左"
End If
ElseIf pre = "上" And a(cur) = "/" Or pre = "下" And a(cur) = "\" Then
If Then
Exit Do
Else
cur = cur - 1: pre = "右"
End If
End If
Loop
Text2.Text = ans + "离开"
End Sub
每项任务有一个紧急程度,用数字表示,数字越大紧急程度越高。紧急程度最高的任务优先执行,紧急程度相同先出现先执行。若某项任务在执行过程中出现了一个紧急程度更高的任务,则正在执行的任务将被暂停,执行该紧急程度更高的任务。
编写VB程序,功能如下:程序运行时,各项任务数据按出现时刻升序显示在列表框List1中,单击“开始”按钮Command1,按照任务完成的先后顺序,在列表框List2显示每项任务的编号以及完成时刻。程序运行界面如图所示:请回答下列问题:
1号任务:时刻1出现,完成所需时长4,紧急程度1
2号任务:时刻2出现,完成所需时长2,紧急程度2
3号任务:时刻7出现,完成所需时长1,紧急程度3
则这3个任务的完成的顺序为(单选,填字母:A . 1号、2号、3号 /B . 2号、3号、1号 / C . 2号、1号、3号)。
Dim id(0 To 100) As Integer '任务编号
Dim t(0 To 100) As Integer '出现时刻
Dim L(0 To 100) As Integer '完成所需时长
Dim v(0 To 100) As Integer '紧急程度
Dim n As Integer '总任务数
Private Sub Form_Load()
'本过程读取任务编号、出现时刻、完成所需时长和紧急程度的数据分别存储在数组 id,t,L和v中,并在List1中显示,代码略
End Sub
Private Sub Command1_Click()
Dim q(0 To 100) As Integer 'q 数组按优先顺序存储已出现的任务编号
Dim k As Integer, i As Integer, j As Integer, cur As Integer
cur = 0: k = 0 'cur 记录当前时刻
For i = 1 To n
Do While k > 0 And t(i) >= cur + L(q(k)) '新的任务出现时,计算并输出已经完成的任务编号
List2.AddItem adj(2, (id(q(k)))) + adj(6, cur + L(q(k)))
cur = cur + L(q(k))
k = k - 1
Loop
If k > 0 Then L(q(k)) = '更新正在执行的任务的完成所需时长
k = k + 1
j = k
Do While v(q(j - 1)) >= v(i)
q(j) = q(j - 1)
j = j - 1
Loop
q(j) = i
Next i
Do While
List2.AddItem adj(2, id(q(k))) + adj(6, cur + L(q(k)))
cur = cur + L(q(k))
k = k - 1
Loop
End Sub
Function adj(x As Integer, v As Integer) As String
'adj可以通过添加前置空格将v转化为x位长度的字符串,便于输出对齐,代码略
End Function