For i= 1 To 49
j=1:a(j)=a(j)+1
Do While a(j)=5
a(j)=0
j = j + 1
a(j) = a(j) + 1
Loop
Next i
数组a中各元素初始值均为0,该程序执行后,数组a中各元素之和为( )
s = 1
For i = 2 To 10 Step 3
s = s + i
Next i
则该程序段执行后,变量s和i的值分别是( )
a(1) = 1
For i = 2 To 6
Randomize
a(i) = a(i - 1) + Int(Rnd * 5 + 1)
If a(i) Mod 2 = 1 Then
a(i) = a(i) \ 2 + 1
Else
a(i) = a(i) / 2
End If
Next i
执行程序后,a数组各元素可能是( )
Key = Val(Text1.Text)
i = 1: j = 100
Do While i <= j
m = (i + j) \ 2
If (1) Then m = m - 1
Sum =(2)
If Key = Sum Then Exit Do ‘Exit Do表示退出循环
If (3) Then
i = m + 2
Else
j = m - 2
End If
Loop
If i > j Then Text2.Text = "没有找到!" Else Text2.Text = Str(m)
实现该功能,则上述程序段3个方框处的表达式分别为( )
Dim i As Integer, j As Integer, a(1 To 5) As Integer
For i =1 To 5
a(i)=Int(Rnd*5+1)
For j = 1 To i-1
If a(i)=a(j) Then
i=i-1 : Exit For
End If
Next j
Next i
执行程序后,数组中的数据可能是( )
s = "123456789"
g = ""
For i = 1 To 3
n = Len(s)
x = Int(Rnd * n) + 1
g = g + Mid(s, x, 1)
s = Mid(s, 1, x - 1) + Mid(s, x + 1, n - x)
Next i
在程序执行时,若变量x的值依次为3,3,6,则最终变量g的值为( )
For i=1 To 3
For j=1 To 5-i
If a(j)>a(j+1) Then
t=a(j): a(j)=a(j+1): a(j+1)=t
End If
Next j
Text1.Text = Text1.Text + Str(a(i))
Next i
数组元素a(1)到a(5)的值依次为“3,9,6,8,4”。该程序段执行后,文本框 Text1 显示的内容是( )
Dim a(1 To 5) As Integer, i As Integer
Dim flag As Boolean, j As Integer
a(1) =1 : a(2) = 1 : a(3) = 1 : a(4)= 1 : a(5) = 1
Randomize
For i = 1 To 5
j = 1: flag = True
Do While j <= i - 1 And flag = True
a(i) = Int(Rnd * 5 + 1)
If a(i) = a(j) Then
i = i - 1: flag = False
End If
j = j + 1
Loop
Next i
运行程序后,数组中的数据值可能是( )
a(1) = 1: a(2) = 3: a(3) = 5: a(4) = 7: a(5) = 9
s = "ICT2019reform"
For i = 1 To 5
t = a(i)
s = Mid(s, 1, t - 1) + Mid(s, t + 1)
Next i
Text1.Text = s
执行该程序段后,Text1显示的是( )
For i = 1 To 5
k = i
For j = i + 1 To 6
If a(k) > a(j) Then k = j
Next j
t = a(k): a(k) = a(i): a(i) = t
b((i + 2) Mod 6 + 1) = a(i)
Next i
s = "Hello World"
s1 = ""
n = Len(s)
For i = 1 To n \ 2
If Mid(s, i, 1) > Mid(s, n - i + 1, 1) Then
s1 = s1 + Mid(s, i, 1)
Else
s1 = Mid(s, n - i + 1, 1) + s1
End If
Next i
Text1.Text = s1
执行该程序段后,在文本框Text1中显示的是( )
Randomize
For i = 1 To 6
a(i) = Int(Rnd * 20) + 1
If a(i) Mod 2 = i Mod 2 Then a(i) = a(i) - 1
Else
a(i) = a(i) + 2 End If
Next i
执行该程序段后,a(1)~ a(6)各元素可能的是( )
Dim a (1 To 6) As Integer
Randomize
a(1) = Int (Rnd*2) + 1
For i = 2 To 6
a(j) = Int (Rnd*i) *2 + 1
If a(i) < a(i-1) Then
a(i) = a(i) + a(i-1)
End If
Next i
执行该程序段后,数组元素a(1)到a(6)的值可能是( )