s=0
For i=1 To 5
a(i)=0
Next i
For i=2 To 5
For j=i To 5
If j Mod i=0 Then
a(j)=a(j)+1
s=s+a(j)
End If
Next j
Next i
运行程序段后,变量s的值为( )
S=“7218634594”:n=Len(s)
t=0
For i=1 To n-1
a(i)=Val(Mid(s,i,2))
Next i
For i=1 To n-2 Step 2
k=i
For j=i+2 To n-1 Step 2
If a(i)<a(k)Then k=j
Next j
If k<>i Then
temp=a(i):a(i)=a(k):a(k)=temp:t=t+1
End If
Next i
Text1.Text=Str(t)
运行程序段后, t的值为( )
Private Sub Command1 Click()
Dim m As Integer,n As Integer
Dim gys As Integer
m=Val(Text1.Text)
n=Val(Text2.Text)
a=m:b=n
Do While m<>n
If ① Then m=m-n Else n=n-m
Loop
gys=n
Label3.Caption=“最小公倍数是:”+ ②
End Sub
① ②
Private Sub Command1_Click()
Dim s1 As String,s2 As String
Dim ch As String,ch2 As String
Dim max As Double
Dim n As Integer,page As Integer
Dim i As Integer,j As Integer
s1=Text1.Text:s2=””
n=Len(s1)
i=1:max=0
Do While i<=n
ch=Mid(s1,i,1)
If ch>=“0”And ch<=“9”Then
j=i
ch2=Mid(s1,i,1)
Do While ch2>=“0”And ch2<=“9”
j=j+1
ch2=Mid(s1,j, 1)
Loop
s2= ’(1)
If Then ’(2)
max=Val(s2)
page=i*10+j-1
Text2.Text=Str(page)
Text3.Text=Str(max Mod l00)
End If
i=j
End If
i=i+1
Loop
End Sub
Const n=3500 ’存储单词的总数
Dim a(1 To n)As String ’依次存储每个英语单词
Dim b(1 To n) As Strin9 ’依次存储每个英语单词的中文含义
Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
conn.ConnectionString=“Provider=Microsoft.ACE.OLEDB.12.0;Data source=”&App.Path&“\dictionary1.accdb”
strSQL=”select*from list”
conn.Open
Set rs.ActiveConnection=conn
rs.Open strSQL
num=0
Do While Not rs.EOF
num=num+1
a(mum)=rs.Fields(“英语单词”)
b(num)=rs.Fields(“中文含义”)
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs=Nothing
Set conn=Nothing
For i==1 To n
List1.AddItem a(i)+“ ”+b(i)
Next i
End Sub
Private Sub Command2_Click()
Dim s As String
S=Text1.Text
If search(s)=-1 Then
Text2.text=“找不到该单词”
Else
Text2.Text= ①
End If
End Sub
Function search(key As String)As Integer
Dim i,j As Integer
Dim mid1,mid2 As Integer
i=1:j=n
search=-1
Do While i<=j
mid1=Int(j+(j—i)/3)
mid2=Int(j-(j-i)/3)
If key=a(mid1)Then
search=mid1
Exit Do
ElseIf key<a(mid1)Then
j=mid1-1
ElseIf key=a(mid2)Then
search=mid2
Exit Do
Elself key>a(mid2)Then
i=mid2+1
Else
i=mid1+1
②
End If
Loop
End Function
① ②