修改时间:2021-05-20 浏览次数:270 类型:月考试卷
数字往后移4个,如0→4,3→7,8→2;字母倒序放在各组前面;“-”不作处理。如字符串“25f-IT4-63t-”,经过处理后变为“f69-TI8-t07-”。下列VB程序段实现该算法,则填空处的代码应该是( )
Const mw = "0123456789"
s = Text1.Text: s1 = "": s2 = ""
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "0" And c <= "9" Then
⑴
⑵
s1 = s1 + c
ElseIf c = "-" Then
⑶
s1 = ""
Else
s1 = c + s1
End If
Next i
j s2 = c+s1+ s2 k c = Mid(mw, t + 1, 1) l c = Mid(mw, t, 1)
m s2 = s2 + s1 + c n t = (Val(c) + 4) Mod 10
Const n=9
k = 1
For i = 1 To (n + 1) / 2 - 1
For j = 1 To n - i * 2
If a(j) * k < a(j + 2) * k Then
t = a(j): a(j) = a(j + 2): a(j + 2) = t
End If
k = -k
Next j
Next i
For i = 1 To (n + 1) \ 2
List2.AddItem Str(a(2 * i - 1))
Next i
已知数组元素 a(1)~a(9)分别是8、6、2、9、6、3、8、11、5,执行程序后list2输出的结果分别是( )
请回答下列问题:
A .flash内包含脚本语言,故flash属于以程序语言为基础的创作工具。B .在多媒体作品设计中,指定使用flash软件制作作品属于创作需求分析。C .在设计制作脚本之前,应该先设计好媒体元素分解表。D .完整的作品制作流程包括作品设计、制作、测试、发布等环节。)
小蓝同学根据上述算法编写了一个VB程序实现比赛结果统计。每场比分记录在文本框text1中,单击“统计”按钮command1,把两队各场的比分按A队小分降序显示在列表框list1输出,同时在文本框text2输出最终结果。部分程序界面如图所示,VB代码如下,回答下列问题:
Private Sub Command1_Click()
Dim a(1 To 20) As Integer, b(1 To 20) As Integer
Dim i As Integer, j As Integer, t As Integer, p As Integer, k As Integer, xiaofen As Integer
‘从文本框读取比分,场次k,AB两队各场的得分分别记录在数组a、b,代码略
For i = 1 To k – 1 ‘对比分数据按A队小分降序排序
For j = 1 To ①
If ② Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
t = b(j): b(j) = b(j + 1): b(j + 1) = t
End If
Next j
Next i
p = 0: xiaofen = 0
For i = 1 To k ‘统计小分并输出比分
If a(i) > b(i) Then ③
xiaofen = xiaofen + a(i) - b(i)
List1.AddItem Str(a(i)) + ":" + Str(b(i))
Next i
If p * 2 > k Or k = p * 2 And xiaofen > 0 Then
Text2.Text = "A队获胜"
ElseIf Then
Text2.Text = "B队获胜"
Else
Text2.Text = "两队战平了"
End If
End Sub
① ② ③
⑴货物逐个尝试放入,搜索场地矩阵(从左到右,从上到下),若某块区域能放下该货物,则标记这些相应位置为货物编号,然后返回左上角检测下一货物。
⑵搜索时,若右侧剩余列小于货物边长,则跳转到下一行,若下方剩余行小于货物边长,则直接返回检测下一货物,直到所有货物检测完毕。
小武同学根据上述算法设计了VB程序。程序运行,在列表框list1降序输出货物规格,点击“存放”按钮command1,在列表框list2输出摆放完成的场地矩阵。
算法的VB程序如下,回答下列问题。
Dim hw(1 To 9) As Integer '存储正方形货物的边长
Dim cd(1 To 100) As Integer '场地是边长为10的正方形
Private Sub Command2_Click()
Dim i As Integer, j As Integer, wz As Integer, s As String
For i = 1 To 9
j = 1
Do While (10 - (j - 1) \ 10) >= hw(i) '下方空间足够
If ① = False Then '从当前位置开始能否放下
j = j + 1
Else
'把相关位置标记为i,并处理下一货物,代码略
End If
If 10 - (j - 1) Mod 10 < hw(i) Then ‘右侧空间不足
②
EndIf
Loop
Next i
‘在列表框list2输出整个场地放好货物之后的矩阵图,代码略
End Sub
Function pd(start As Integer, bc As Integer) As Boolean
Dim i As Integer, wz As Integer
pd = True: wz = start
Do While wz <= start + 11* (bc - 1) And wz <= 100
If ③ Then
pd = False
Exit Function
ElseIf (wz - 1) Mod 10 - (start - 1) Mod 10 = bc - 1 Then
wz = wz + 11 - bc ‘位置转到下一行,与起点同列
Else
wz = wz + 1
End If
Loop
End Function
Private Sub Form_Load()
‘生成货物边长,降序显示在列表框list1,矩阵元素初始化为0,代码略
End Sub
① ② ③
试题篮