flag=False: s="ShanShui2020!"
For i=1 To Len(s)
ch=Mid(s,i,1)
If Not(ch>="0" And ch<="9")And Not flag Then
t=ch+t
End If
flag=Not flag
Next i
Text1.Text=t
执行完以上程序段后,文本框text1中的内容为( )
i=1:j=8:k=0
key=15
Do While i<=j
k=k+1
m=Int((i+j)/2)
If key<a(m)Then j=m-1 Else i=m+1
Loop
数组元素a(1)到a(8)的数据依次是“14,15,15,17,28,30,37,40”,该程序执行完毕后,下列各变量的值不正确的是( )
Dim a(1 To 6)As Integer
For i=1 To 6
a(i)=Int(Rnd()*45)*2+10
Next i
For i=1 To 2
For j=2 To 6-i
If a(j)\10>a(j-1)\10 Then
temp=a(j):a(j)=a(j-1):a(j-1)=temp
End If
Next j
Next i
执行上述程序段后,下列选项中,a(1)到a(6)各元素值可能的是( )
图b
图c
请回答下面问题:
Private Sub Command1_Click()
Dim n,i,j,k,x,L,R,c As Integer
Dim goods(1 To 20)As String 'goods(i)存储商品的名称
Dim price(1To 20)As Integer 'price(i)存储商品的价格
Dim s,ch As String
s=Text1.Text:x=Val(Text2. Text)
j=1:k=0
For i=1 To Len(s)
ch=Mid(s,i,1)
If ch="," Then
k=k+1
If k Mod 2=1 Then
Else
price(k\2)=Val(Mid(s,j,i-j))
End If
j=i+1
End If
Next i
n=k\2
For i=1 To n-1
For i=1 To n-i
If price(j)>price(j+1)Then
k=price(j):price(j)=price(j+1):price(j+1)=k
End If
Next j
Next i
For i=2 To n
L=i:R=n
Do While L<=R
m=(L+R)\2
If price(m)+price(k)=x Then
c=c+1
List1. Addltem goods(k)& Str(price(k))&"元 和" & goods(m)& Str(price(m))& "元"
j=m
Do While price(j)=price(j-1)
j=j-1
c=c+1
Listl. Addltem goods(k)& Str(price(k))& "元 和" & goods(j)& Str(price(j))& "元"
Loop
Do While
m=m+1
c=c+1
List1. Addltem goods(k)& Str(price(k))& "元 和" & goods(m)& Str(price(m))& "元"
Loop
Exit Do ‘Exit Do 表示退出Do循环
Elself price(m)+price(k)>x Then
R=m-1
Else
L=m+1
End If
Loop
Next i
List1. Addltem"共有:" & Str(c)& "种组合"
End Sub
Private Sub Command1_Click()
Dim a(1 To 20)As String
Dim n,m,i,j As Integer
Dims,s1,s2 As String
s1=Text1. Text:n=Len(s1)
m=0:s=""
For i=1 To n
If Mid(s1,i,1)="" Or Mid(s1,i,1)="." Then
m=m+1
a(m)=s
s=""
Else
End If
Next i
For j=1 To m
n=Len(a(j))
For k=1 To n
If t﹥="a" And t<="z" Then
s2=s2+t
Else
s2=s2+t
End If
Next k
Text2. Text=Text2. Text+s2
s2=" "
Next j
Text2. Text=Text2. Text & "."
End Sub