
Private Sub Command1_Click( )
Dim st As String
Dim i As Integer, j As Integer
Dim flag As Boolean
①
J= Len (st)
i=1
flag=True
Do While flag And (i < = j)
If Mid(st,i,1)= mid (st,j,1) Then
i=i+1
②
Else
flag=False
End If
Loop
If ③ then
Text2. Text = “yes”
Else
Text2. Text = “no”
End If
End Sub
① ② ③
Private Sub Commandl_Click()
Dim f As Integer,i As Integer
Dim s As
‘①
f=1:i=1:s=0
DoWhile
‘②
s=s+f * 1/i
f=-1*f
i=i+2
Loop
Text1.Text=Str(s)
End Sub
下列说法正确的是( )
Private Sub Command 1_Click()
Dim s As String,ch As String
Dim i As Integer,n As Integer
Dim max1 As Integer,max2 As Integer
s=Text1.Text:n=Len(Text1.Text)
If Mid(s,1,1)>Mid(s,2,1)Then
max 1=1:max2=2
Else
max1=2:max2=1
End If
For i=3 To n
ch=Mid(s,i,1)
If ch>Mid(s,max1,1)Then
①
max1=i
ElseIf ch>=Mid(s,max2,1)Then
max2=i
End If
Next i
For i=1To n
If ② Then Text2.Text=Text2.Text&Mid(s,i,1)
Next i
End Sub
① ②
Private Sub Text1_Change()
Dim a As Integer, i As Integer
a = Val(Text1.Text)
For i = 1 To 7 Step 3
If a <= 1000 Then a = a + i
Next i
Text1.Text = Str(a)
End Sub
执行该程序段,在文本框Text1中分别输入“1”、“2”、“3”、“4”,Text1中的结果( )
s1 = "abcde"
j = 1
s2 = "a"
For i = 1 To Len(s1)
j = (j + 2) Mod Len(s1) + 1
s2 = s2 + Mid(s1, j, 1)
Next i
Text1. Text = s2
执行该程序段后,文本框Text1中输出的内容是( )
Dim a(1 to 6) as Integer
s = 0
Do While s <= 5
t = Int(Rnd * 6 +1)
a(t) = a(t) + 1
If a(t) = 1 Then s = s + a(t)
Loop
已知数组a(1)到a(6)的初值均为0,运行该程序段后,a(1)到a(6)不可能是( )
实现上述功能的程序如下,请在划线处填入合适的代码。
def isprime(x):
for i in range(2,x):
If:
return False
return True
n=int(input(“请输入一个正整数n:”))
c=0
k=3
while k<=n-2:
if isprime(k) and:
print(k,k+2)
k=k+1
print(“共有”+str(c)+“对双胞胎数”)
____
a,b=[0]*10,[False]*10
i=0
while i<=9:
____
if not b[r]:
a[i]=r
____
i=i+1
print(a)
则划线处的代码依次是( )
① r=random.randint(0,10)
② b[r]=True
③import random
④ b[i]=True
⑤from random import randint
⑥ r=random.randint(0,9)
i=n 'n为数组a中的元素个数
do while i>0 and a(i)>x
i=i-1
loop
a(i+1)=x