内容正文:
考点9 基本程序解读
姓名: 班级:
1. 有如下VB程序段:
m=a(1):s=0
For i=2 To 5
If a(i)> m Then m =a(i)
S = s + m
Next i
数组元素a(1)到a(5)的值依次为“1,3,42,3”,执行该程序段后,变量s的值为( )
A.7 B.12 C.13 D.15
2. 有如下VB程序段:
s1 = "1324": s2 = "abcdefgh"
j=1:m=0:c=“”
For i=1 To Len(s2)
k= Val(Mid(s1, j,1))
c = c + Mid(s2, m+k,1)
j=j+l
If j > 4 Then j = 1:m = m + 4
Next i
执行该程序段后,变量c的值是( )
A."acbdegfh" B."acbdacbd" C."acbdefgh" D."abcdefgh"
3. 有如下VB程序段:s1="BGR":s2="VBPROGRAM"
i = 1:j= 1:s3 = ""
Do While i < = Len(s) and i<=Len(s2)
If Mid(s1,i,1)=Mid(s2,j,1)Then
i= i+1
Else
s3 =s3 +Mid(s2,j,1)
End If
j=j+1
Loop
执行该程序段后,变量s3的值是( )
A. "VPO" B. "VPRO" C. "VPOAM" D. "VPROAM"
4.有如下VB程序段:
result=""
p= Text1.Text
k= Text2.Text
i=1
Do While i <= Len(p)
If Mid(p, i, Len(k)) <> k Then
result = result + Mid(p, i, 1)
i=i+1
Else
i = i + Len(k)
End If
Loop
在文本框Text1和Text2中分别输入"viarectory"和"are",执行该程序段后,变量result的值是( )
A. "victoryare" B. "arevictory" C. "viarectory" D."victory"
5.有如下VB程序段:
S= "PYTHON"
t= "8421"
result=””
For i=1 To Len(t)
x= Val(Mid(t, i,1))
y=(x - 1)Mod Len(s) + 1
result=result+Mid(s, y, 1)
Next i
Text1. Text=result
执行上述程序段后,文本框Text1中显示的是( )
A. PYHY B.PTPT C.TPTP D.YHYP
6.某随机秘钥生产程序的VB程序段如下:
s =”XFeng@JinHua”
n = Len(s)
i = 0: c = 1: ans =""
Do While c <= 4
m = Int(Rnd * 6 + 1)
i = (i + m - 1) Mod n + 1
ans = ans + Mid(s, i, 1)
c=c+1
Loop
Text1. Text = ans
执行该程序段后,文本框中不可能的输出是( )
A. XFen B.eiua C.@XFg D.FJHX
7.有如下VB程序段:
s= "python2021":t="":i=1
Do While i< Len(s)
c = Mid(s,i,1):d=Mid(s,i+1,1)
If c<d Then t= t+c Else t=t+d
i=i+2
Loop
Lab