礼品分配问题:某班得到一件精美礼品,由于只有一件礼品,大家决定用下面方法来分配该礼品:n个同学围成一圈,按顺序从1到n进行编号。从第1个人开始报数,报到 m 的人退出,下一个人继续从1开始报数,报到m的人出圈┈┈,如此依次进行,直到留下的最后一个人得到该礼品。程序运行界面如图所示,单击“开始”按钮,将输出退出圈子的同学编号以及最后获得奖品的编号。
实现上述功能的VB程序如下,请回答下列问题。
Private Sub Command1_Click()
Dim i As Integer, n As Integer, m As Integer
Dim num As Integer, t As Integer
Dim a(1 To 100) As Boolean
n = Val(Text1.Text)
m = Val(Text2.Text)
For i = 1 To n
a(i) = True
Next i
①
Do While t > 1
For i = 1 To n
If a(i) = True Then ②
If num = m The
③
t = t - 1
num = 0
Text3.Text = Text3.Text + Str(i)
End If
Next i
Loop
For i = 1 To n
If a(i) = True Then Label2.Caption ="获得礼品同学编号:" + Str(i)
Next i
End Sub