


Private Sub Command1_Click()
Dim i As Integer, j As Integer, c As Integer,n As Long
c = 0
n = 110800 + i
If Then
List1.AddItem Str(n) + " " + "5"
End If
Next i
Label2.Caption = "满足条件的数有:" + Str(c) + "组"
End Sub
以原文:Hello,密钥:123为例,“H”转换为ASCII码后加上密钥的第一个数字1,再转换回ASCII字符,得到“I”;“e”转换为ASCII码,加上密钥的第二个数字2,转换回ASCII得到“g”;“l”则加上密钥的第三个数字3得到“o”;随后原文又出现“1”,但是密钥中的数字已经用完了,则密钥从头开始,加上“1”,得到“m”;“o”则得到“q”,最后产生密文“Igomq”。
具体程序如下,但是有两处加框的代码错误,请改正:
Dim code As String, key As String
Dim i As Integer, res_code As String
Dim l_code As Integer, l_key as Integer
Private Sub Command1_Click( )’加密程序
code = Text1.Text
key = Text2.Text
l_code =Len(code)
l_key =Len(key)
res_code = “”
For i = 1 To
‘⑴
c =Asc(Mid(code, i, 1))
k =
‘⑵
res_code = res_code +Chr(k + c)
Next i
Text3.Text = res_code
End Sub
Private Sub Command2_Click( )
‘解密程序略
End Sub
⑴ ⑵
Private Sub Command1_Click()
Dim a(1 To 6) As Integer, b(1 To 6) As String, i as integer, j as integer
Dim c As String, k As Integer, tmp1 As Integer, tmp2 As String
s=text1.text
i = 1: k = 1: tmp1 = 0: tmp2 = ""
Do While i <= Len(s)
c = Mid(s, i, 1)
If c = "," Then
a(k) = tmp1: b(k) = tmp2
tmp1 = 0: tmp2 = ""
①
Else
If
Then
tmp2 = tmp2 + c
Else
tmp1=tmp1*10+val(c)
End If
End If
i = i + 1
Loop
For i = 1 To 5
For j = 1 To 6 - i
If a(j) > a(j + 1) Then tmp1 = a(j): a(j) = a(j + 1): a(j + 1) = tmp1
If Len(b(j)) > Len(b(j + 1)) Or ② Then
tmp2 = b(j): b(j) = b(j + 1): b(j + 1) = tmp2
End If
Next j
Next i
For i = 1 To 6
List1.AddItem Str(a(i)) + b(i)
Next i
End Sub
① ②
Dim a(1 To 15) As Integer
Private Sub Form_Load()
Dim i As Integer, t As Integer
Dim s1 As String, s2 As String
Randomize
s1 = ""
For i = 1 To 15
a(i) = ①
s1 = s1 + Str(a(i))
Next i
Text1.Text = s1
End Sub
Private Sub Com1_Click()
s2 = ""
For i = 1 To 15
s2 = ②
Next i
Text2.Text = s2
End Sub
① ②

Private Sub Command1_Click()
Dim s As String,s1 As String,c As String
s=Text1.Text
For i=1 To Len(s)
c=Mid(s,i,1)
s1= ⑴
For j= ⑵
If c<>Mid(s,j, 1)Then
s1=s1+Mid(s,j,1)
End If
Next j
⑶
Next i
Text2.Text=s
End Sub
Randomize
a(0)=0:i=1
Do While i<= 7
a(i) =Int(Rnd*10) *3+ 1
If i Mod 2= 1 Then
a(i)=a(i)+a(i-1)
ElseIf a(i) Mod 2= 1 Then
i=i-1
End If
i=i+1
Loop
执行该程序段后,a(1)~a(7)各元素可能的值为( )
Dim s As String, ch As String
Dim i As Integer, t As Integer
s = Text1.Text : t = 0
For i = 1 To Len(s)
ch = Mid(s, i, 1)
If ch <> "," Then t = t * 2 + Val(ch)
Text2.Text = Text2.Text + Str(t)
Next i
执行该程序,当文本框text1中输入了“11,10”时,文本框text2中输出的是( )
小王同学编写了一个VB程序,功能如下:在列表框List1中随机生成n个1~1000之间的整数,单击“运行”按钮Command1后进行处理,最大整数结果输出在文本框Text1中。当n=5时,程序运行界面如图所示。
实现上述功能的VB程序如下,请回答下列问题:
Const n=5
Dim a(1 To 10)As Integer
Private Sub Command1_Click( )
Dim i, j, t As Integer
For i=1 Ton-1
For j=n To i+1 Step-1
If ① Then
t=a(j-1):a(j-1)=a(j):a(j)=t
End If
Next j
Next i
For i=1 To n
Text2. Text=Text2. Text+Str(a(i))
Next i
End Sub
Private Sub Form_Load( )
Randomize
For i=1 To n
a(i)= ②
Text1. Text=Text1. Text +Str(a(i))
Next i
End Sub
Function cmp(a As Integer,b As Integer) As Boolean
If Str(a)+Str(b)<Str(b)+Str(a) Then
cmp=True
Else
cmp=False
End If
End Function
以上程序段运行时,为了实现上述功能,画线处应填入的代码分别为:①;②。
对应的Python表达式是(r1、r2和r3分别对应变量
、
和
)( )
B . r1/(r1+r2)u
C . r1/(r1+r2)·u
D . r1/(r1+r2)*u
| m= 29 if m%3!=0: print (m, "不能被3整除") else print (m,“能被3整除") |