题型:单选题 题类:常考题 难易度:普通
浙江省高中信息技术 算法及VB语言基础单元检测
Dim i As Integer, Sum As Integer
Dim a(1 To 6) As Integer, b(1 To 6) As Integer
Sum = 0
a(6) = 18: a(5) = 7: b(6) = 14: b(5) = 16
For i = 4 To 1 Step -1
a(i) = a(i+2)-a(i+1)
b(i) = b(i+2)-a(i)
If b(i) Mod 3 = 0 Then Sum = Sum + b(i)
Next i
Textl .Text = Str(Sum)
该程序段运行后,文本框text1中显示的内容是( )
长度小于等于 100),在列表框 List1 里输出所有配对括号在表达式中的位置。例如在文本框 Text1 里入:“12*(3-(1+2))*3”,程序运行效果如图所示。
实现上述功能的 VB 代码如下,在划线的地方填入合适代码,完善程序。Private Sub Command1_Click()
Dim s As String
Dim a(1 To 100) As Integer
|
i = 1 top = 0
Do While i <= Len(s)
If Mid(s, i, 1) = "(" Then
top = top + 1
{#blank#}1{#/blank#}
End If
If Mid(s, i, 1) = ")" Then
List1.AddItem Str(a(top)) + " " + Str(i)
{#blank#}2{#/blank#}
End If
i=i+1 Loop
End Sub
试题篮