①Sqr(Abs(-4)) Mod 3 + 5
②Fix(-8.8)\3*2
③Int(-11.2)\3*2
④3 ^ 2 - Len("1+1=2")
s = Text1.Text: p = 0: Sum = 0
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "0" And c <= "9" Then p = p * 10 + Val(c)
Else
Sum = Sum + p
p = 0
End If
Next i
在文本框text1输入"12rtt20pK8",程序运行后sum的值是( )
n= ①
Do while ②
tmp=n mod 2
③
④
Loop[
Label1.Caption=s
则为实现上述功能,正确的代码顺序应该是( )
Dim a(1 To 5) As Integer, i As Integer
a(1) = 1: a(2) = 1
For i = 3 To 5
a(i) = a(i - 1) + a(i - 2)
Next i
Text1 Text = Str(a(i - 1))
该程序段运行后,文本框Text1中显示的内容是( )
图 b
图 c
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer
Dim x1 As Single, x2 As Single, x3 As Single, t As Single Dim Totald As Integer, v As Single, s As String
s = Text1.Text
k = 0: j = 1: Totald = 0
For i = 1 To Len(s)
If Mid(s, i, 1) = "," Then
v = Val(Mid(s, j, i - j)) '提取三角形边长,保存在变量v中
①
If k Mod 3 = 1 Then
x1 = v
ElseIf k Mod 3 = 2 Then x2 = v
If x1 < x2 Then t = x1: x1 = x2: x2 = t
Else
x3 = v
If x1 < x3 Then t = x1: x1 = x3: x3 = t
If ② Then Totald = Totald + 1
End If
End If
Next i
Label1.Caption = "一共构成" + Str(Totald) + " 个直角三角形"
End Sub
① ②
1)将明文中的字母E替换为A,F替换为B,G替换为C,…A替换为W,B替换为X,C替换为Y,…,小写字符的替换方法同理。
如:明文:I Love China 加密为:E Hkra Ydejw
2)将加密后的英文字母,按顺序依次放入每个字符串段落中,第1个加密字母E放在第1个段落,第2个字母H放在第2个段落,依次类推(如下图),段落间用逗号分隔并以逗号结尾。当遇到空格,在段落末尾“,”前,插入“+”号作为标记。
第1段 | 第2段 | 第3段 | 第4段 | 第5段 | 第6段 | 第7段 | 第8段 | 第9段 | 第10段 |
E+, | H, | k, | r, | a+, | Y, | d, | e, | j, | w+, |
3)每个段落中,随机插入字母形成新的字母序列段,当段号小于8时加密字母在字母序列
中存放位置刚好是该段落号,位置以8为周期,第9段时,加密字母存放位置回到字母序列的第1位,第10段加密字母存放位置回到第2位,依次类推。(位置号<=8)
第1段 | 第2段 | 第3段 | 第4段 | 第5段 |
Etc+, | mHfryh, | oTkrestf, | rfir, | Ccfta+, |
第6段 | 第7段 | 第8段 | 第9段 | 第10段 |
iynhyYf, | tqswjyd, | nrtesiueh, | jnytq, | Uwccdb+, |
4)在每一段中随机插入除英文字母之外的ASCII字符码,形成一串密文。如图所示:
则根据加密算法,解密后的明文为
Private Sub Command1_Click()
Dim i As Integer, k As Integer
Dim s As String, c As String, ch As String
Dim letter As String, ret As String 'letter 用于存放字母序列s = Text1.Text
k = 1
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "A" And c <= "Z" Or c >= "a" And c <= "z" Then letter = letter + c
ElseIf
c = ","
Then
ch = Chr(Asc(ch) + 4)
If Not (ch >= "A" And ch <= "Z" Or ch >= "a" And ch <= "z") Then ch = Chr(Asc(ch) - 26)
End If
IfThen ret = ret + ch + " "
Else
ret = ret + ch
End If
k = k + 1
End If
Next i
Text 2.Text = ret
End Sub