移红包规则:
①编号为1的堆上的红包,只能移到编号为2的堆上;
②编号为n的堆上的红包,只能移到编号为n-1的堆上;
③其它堆上的红包,可以移到相邻左边或右边的堆上。
现要求找出最少的移动次数使每堆的红包数-样多。如图所示,在文本框Text1中输入红包堆数n,在文本框Text2中依次输入每堆红包的红包个数(以“,”为分隔符和结束符),单击“移红包次数统计”按钮Command1后,在标签Labe13中显示最少的移动次数。

(1)代码“Private Sub Command1_ Click()”中的Click是______(单选,填字母:
A.对象名 | B.事件名 | C.事件处理过程名 | D.方法名) |
Const Sum = 40 '红包总个数
Private Sub Command1_ Click ()
Dim n As Integer '红包的堆数
Dim s As String, k As Integer
Dim avg As Integer '最终每堆的红包个数
Dim ml As Integer, m2 As Integer
Dim tmp As Integer, count As Integer, ans As Integer
n= __________
s = Text2. Text
avg=Sum/n
tmp=0:count=0:ans=0
For k=1 To Len(s)
c = Mid(s, k, 1)
If c <>","Then
tmp =_ _________
Else
count = count + 1
If count = 1 Then
ml =tmp
Else
m2 = tmp
If ml <> avg Then
m2=m2-(avg-m1)
ans=ans+1
End If
________
End If
tmp=0
End If
Next k
Labe13. Caption = Str (ans)
End Sub

同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

