序号 | 产品编号 | 类别名称 | 价格(元) | 折扣 | 好评度 | 是否下架 |
1 | znsh03 1 | 智能手环 | 399 | 85% | ★★ | 否 |
2 | znsb028 | 智能手表 | 2000 | 90% | ★★★★ | 是 |
… | … | … | … | … | … | … |
下列相关描述,正确的是( )
s="67.153.47.211"
n = Len(s)
ch=”":cmax= ""
For i= 1 Ton
c=Mid(s,n-i+1,1)
If c>="0" And c<="9" Then
ch=ch+c
Else
If ch> cmax Then cmax = ch
ch=""
End If
Next i
Text1.Text = cmax
执行该程序段后,文本框Text1中显示的内容是( )
i=1:s=0
Do Whilei<= 5
a(i)=Int(Rnd*8)+2
For j= 1 To i-1
s=s+ a(j)
Next j
If i>= 2 And a(i)> s Theni=i-1
s=0
i=i+ 1
Loop
执行该程序段后,在下列选项中,a(1)~a(5)各元素值不可能的是( )
k1 = 1:k2= 10
For i=2 To 10
If a(i) < a(k1) Then
ElseIf a(i) < a(k2) Then
End If
Next i
Text1.Text = Str(a(k1)) + "," + Str(a(k2))
上述程序中方框处可选语句为:
①k1=i
②k2= i
③k2= k1
则⑴⑵⑶处语句依次是( )
i=1:j=8:s=0:c=0
Key= Int(Rnd * 10) +41
flag = True
Do Whilei<= j And flag
c=c+ 1
m-(i+j)\2
If Key = a(m) Then flag = False
If Key < a(m) Thenj=m-1 Elsei=m+ 1
s=s* 10+ m
Loop
数组元素a(1)到a(8)的值依次为“10,20,30,40,50,60,70,80”,执行该程序段后,下列说法错误的是( )
请回答下列问题。
Constn= 10
Dim a(1 To n) As Integer
Private Sub Command1_ Click()
Dim Left As Integer, Right As Integer, Lstart As Integer, Rstart As Integer
Dim i As Integer, j As Integer, t As Integer, s As String
'随机生成n个不重复元素的数组a,并在左边环形显示,代码略
k= 1
For i= 2 Ton
If a(i) < a(k) Thenk=i
Next i
Lstart = (k+n- 2) Mod n+ 1: Rstart= k Mod n+ 1
i= 1
Do Whilei<= (n-1)\2
Left = Lstart
For j= 1 To
p= (Left+ n-2) Mod n+ 1
If a(Left) > a(p) Then
t= a(Left): a(Left) = a(p): a(p)= t
End If
Left= p
Next j
Rstart= Rstart Mod n + 1
Right = Rstart
Do While
p=RightModn+1
If Then
t= a(Right): a(Right) = a(p): a(p)=t
End If
Right= p
Loop
Lstart =
i=i+ 1
Loop
排序后的数据在右边环形显示,代码略
End Sub
1)首先生成一段由字母“a,b,c,A,B,C"随机组成的字符串s;
2)对字符串s从左到右寻找3个及以上连续相同字母(不区分大小写)组成的字符串并进行消除;
3)对消除后的重组字符串再进行相同消除操作,直至完成所有消除操作。
例如,生成字符串s为“BCbbaabAbAaaA",第1次消除字符串“aaa” 后,字符串s重组为“BCcbbbAbAaaA”;第2次消除字符串“bbb" 后,字符串s重组为“BCcAbAaaA”;第3次消除字符串“AaaA” 后,字符串s重组为“BCcAb”。
小陈编写了VB程序,功能如下:单击“生成字符串”按钮Command1, 随机生成由字母“a,b,c,A,B,C”组成的字符串s并显示在文本框Text1中,单击“消除”按钮Command2,在列表框List1中显示各次消除的字符串,在文本框Text2中显示消除后的字符串。程序运行界面如图所示。
(提示:字母“a”的ascii码值为97,字母“A”的asci码值为65)
Dim a(1 To 100) As String
Dim b(1 To 100) As String
Dim s As String
Constn= 15
Private Sub Command1_ Click0
Dim i As Integer
Randomize
For i= 1 To n
a(i)= Cr
s=s+ a(i)
Next i
Text1.Text=s
End Sub
Private Sub Command2 _Click)
Dim I As Integer, j As Integer, m As Integer, k As Integer
i=1
m= 1
Do Whilei <= Len(s) -2
k=i
Do While IsSame(a(i), a(i + 1)) Andi<= Len(s)- 1
i=i+ 1
If i= n Then Exit Do
Loop
If i-k>= 2 Then
b(m) =
List1 AddItem "第" + Str(m) + "次消除的字符: " + b(m)
m=m+ 1
s= Mid(s, 1, k- 1) + Mid(s, i+ 1, Len(S)-i)
For j= 1 To Len(s)
a(j)= Mid(s, j, 1)
Next j
i=k-3
If i<0 Then i=0
End If
i=i+1
Loop
Text2.Text=s
End Sub
Function IsSame(p As String, q As String) As Boolean
IsSame = False
If Then
IsSame = True
End If
End Function