a=4: b=3
If a >= 4 Then
If b < 2 Then a=a+2
If b > 2 Then a=a+3
a=a+2
ElseIf a >= 9 Then
a=a+4
Else
a=a+b
End If
Const n = 15
Const m = 100 '整数的最大值
Dim a(1 To n) As Integer
'本过程产生n个不同随机整数,区间在[1,m]之间,存储在数组a中,代码略
Private Sub Command1_Click()
Dim i As Integer
Dim flag(1 To m) As Boolean
For i = 1 To n
① = True
Next i
For i =2 To m step 2
If flag(i) Then List2.AddItem ②
Next i
For i = ③ To 1 Step -2
If flag(i) Then List2.AddItem Str(i)
Next i
End Sub
Private Sub Command1_Click()
Dim a(1 to 10) As Integer
Dim i As Integer, j As Integer, Key As Integer, c As Integer, m As Integer
Dim flag As boolean
flag = True: c = 0
i = 1: j = 10
Key = Int(Rnd() * 17) + 8
Do While i <= j And flag = True
c = c + 1
m = (i + j) \ 2
If Key = a(m) Then
flag = False
ElseIf Key > a(m) Then
j = m - 1
Else
i = m + 1
End If
Loop
End sub
数组元素a(1)到a(10)的值依次为50、45、40、35、27、24、15、7、5、3,程序运行后变量c的值可能是:( )
A.选择“背景”图层,将不透明改为0%,并以PNG格式存储可以得到背景透明的图像文件。
B.选中“太阳图形”图层,通过“自由变换”改变太阳的大小,扇面赛道图层的内容大小也会同步变化。
C.选中“背景”图层,不可以直接设置图层样式,但可以直接添加滤镜。
D.拷贝“文字”图层的图层样式,并粘贴到扇面赛道图层,扇面赛道图层中可见的图层样式有2种。
E.选中“文字”图层,利用文字工具可以选中单个文字,并设置文字大小和颜色。
小李在“按钮”图层的第72 帧设置脚本命令“Stop();”,测试影片时,动画播放到第72帧停止,但“帮助”图层中的帮助实例在动画停止时仍然保持飘动状态,那么该实例的元件类型是 。
Dim m As Integer
Dim a(1 To 100) As Integer
Private Sub Command1_Click()
'输入整数m,并随机产生m2个随机数
'随机数以m*m 矩阵形式在List1上显示
'代码略
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer ,t As Integer, k As Integer,
Dim s As String
List2.Clear
For i = 1 To m * m
k = i
For j = i + 1 To ①
If a(j) < a(k) Then k = j
Next j
If k <> i Then t = a(k): a(k) = a(i): a(i) = t
②
If Then
List2.AddItem s
s = ""
End If
Next i
End Sub
① ②
丽华设计如下算法:考虑到方案中只包含了A与B两个字母,可以用二进制的0和1来代替(0表示A,1表示B)。当全部是0时最小,此数0;当全部是1时此数最大。枚举0到最大数的每一种情况,逐一判断是否包含B相连(二进制数1相连)情况,符合条件的0、1转为A、B后输出。
根据以上算法思想,丽华使用VB程序编写了一个程序来解决这个问题。在文本框Text1中输入n的值,点击“寻找方案”按钮Command1后,在列表框List1中输出所有的方案,在标签Label3中显示方案总数。
Private Sub Command1_Click()
Dim i As Integer, j As Integer, n As Integer, t As Integer, k As Integer
Dim flag as Boolean, ans As Integer
Dim a(1 To 15) As Integer
n = Val(Text1.Text)
For i = 0 To 2^n-1
t = i
For j = 1 To n
a(j) = t Mod 2
t = t \ 2
Next j
flag = True
For k = 1 To n-1
If Then flag = False
Next k
If flag Then : ans = ans + 1
Next i
Label3.Caption = "可能方案共" + Str(ans) + "种"
End Sub
Function GetStr(x As Integer, n As Integer) As String
Dim m As Integer, i As Integer
GetStr = ""
m = x
For i = 1 To n
If m Mod 2 = 0 Then
GetStr = "A" + GetStr
Else
GetStr = "B" + GetStr
End If
Next i
End Function