s= Text1. Text '输人的英语短文
t= Text2. Text '要统计的开头字母
b=Len(s): f = True
For i=1 To b
c = Mid(s, i, 1)
If ① Then
n= n+1
②
ElseIf c = "" Or c= "." Then
③
Else
f = False
End If
Next i
Label1.Caption= "以" + t + "为开头的单词个数:" + Str(n)
为实现上述程序,划线处应填入的代码是( )
a(0)= Int(Rnd() * 6+95)
For i=1 to 5
a(i)=a(i-1)-Int(Rnd() * 6)
If i Mod 2=0 then
a(i)=a(i)+a(i) Mod 2
End if
Next i
执行该程序段后,在下列选项中,a(0)~a(5)各元素值可能是( )
i=1:j=100:Key=20
Do While i<=j
a = i+(j- i)\4: b= i+(j- i)\ 2:c=j-(j-i)\4
If a=Key Or b=Key Or c=Key Then ExitD o
If i<= Key And Key< a Then j= a- 1: w= w+ 1
If a< Key And Key < b Theni = a+ 1: j= b-1:x=x+1
If b < Key And Key < c Then i= b+1:j=c-l:y=y+1
If c<Key And Key<=j Then i=c+1:z=z+1
Loop
n=w+x+y+z
程序运行结束后,变量n的值是( )
n = 8: flag = True: c=0: x=1: y=n
Do While flag
p = False: flag = False
For j=y To x+1 Step-1
c=c+1
If a(j) < a(j- 1) Then
t=a(j): a(j)=a(j-1): a(j-1)=t
x =j: flag =True
If p=False Then y=j: p=True
End If
Next j
If y <> n Then y= y+ 1
Loop
数组a(1)到a(8)值依次为“4,10,15,18,16,17,20,25”,程序运行后,变量c的值为( )
Dim n As Integer '总人数
Dim dq(1 To 2000) As String
Dim xm(1 To 2000) As String
Dim tw(1 To 2000) As Single
Dim city(1 To 100) As String
Dim citynum(1 To 100) As Integer
Dim citys As Integer
Private Sub Form_ Load()
'该过程的作用从数据库读取n个患者的信息,并在列表框List1输出所有患者的地区、姓名、体温信息。
'dq数组存储患者的地区信息
'xm数组存储患者的姓名信息
'tw数组存储患者的体温信息
'代码略
End Sub
Private Sub Command1_Click()
Dim i, j As Integer
Dim s As String, t As Integer
citys=0
For i=1 To n
If tw(i)>>=37.4 Then
For j = 1 To citys
If Then citynum(j) = citynum(j) +1: Exit For
Next j
If j> citys Then citys = citys +1: city(citys) = dq(i) : citynum(citys) = 1
End If
Next i
For i=1 To citys-1
For j = citys Toi + 1 Step -1
If Then
s = city(j): city(j) = city(i): city(i) = s
t = citynum(j): citynum(j) = citynum(i): citynum(i) = t
End If
Next j
Next i
For i=1 To citys
List2. AddItem city(i)+" "+Str( citynum(i))
Next i
End Sub
Private Sub Command2_ Click( )
Dimi, j As Integer
For
For j=1 To n
If dq(j) = city(i) And tw(j) >= 37.4 Then
List3. AddItem dq(j) + ""+ xm(j) + ""+ Str(tw(j))
End If
Next j
Next i
End Sub
小王设计VB程序如下,在标签.上显示南岸城市的位置序号,例如“1,2,3,4,5,"(两岸城市序号之间用逗号分隔),然后按照南岸城市的顺序在Text1中输入相应的北岸友好城市序号“3,2,4,1,5,”,其中南岸1号城市与北岸3号城市为友好城市,南岸2号城市与北岸2号城市为友好城市,以此类推,单击“分析”按钮,显示最多可批准的申请数量为3个(如图16-2所示),最终政府批准的3条航道为南岸城市2-北岸城市 2,南岸城市3-北岸城市 4,南岸城市5-北岸城市5。
Private Sub Command1_ Click()
Dim b(1 To 100) As Integer 'b(i)表示编号i南岸城市对应的北岸友好城市
Dim c(1 To 100) As Integer
Dim n1, lenc As Integer
Dim i, j As Integer
Dim s1 As String
Dim st, ch As String
Dim flag As Boolean
n1=0
s1 = Text1. Text
st =""
For i = 1 To Len(s1)
ch = Mid(s1, i, 1)
If ch = "," Then
n1 = n1+1
st =""
Else
st=st+ch
End If
Next i
c(1) = b(1)
lenc = 1
For i=2 To n1
If b(i) > c(lenc) Then
lenc=lenc+1
c(lenc) = b(i)
Else
j=lenc-1: flag=True
Do While j>= 1 And flag
If Then
c(j+1)=b(i)
flag = Flase
End If
j=j-1
Loop
If j = 0 And flag Then
End If
End If
Next i
Label1. Caption = "最多批准申请数:" + Str(lenc) + "个"
End Sub