VB 有十七个人围成一圈(编号为0~16),第0号的人开始从1报数,凡报到3的倍数的人离开圈子,然后再数下去

ibii77772022-10-04 11:39:541条回答

VB 有十七个人围成一圈(编号为0~16),第0号的人开始从1报数,凡报到3的倍数的人离开圈子,然后再数下去
直到最后只剩下一个人为止.问此人原来的位置号是多少?
要的是程序!

已提交,审核后显示!提交回复

共1条回复
ryh5858 共回答了12个问题 | 采纳率100%

Private Sub Command1_Click()
Form1.Cls
Dim a(1 To 17) As Integer
Dim i As Integer,j As Integer,k As Integer
For i = 1 To 17
a(i) = i - 1
Next
i = 0
j = 0
k = 17
Do While k > 1
For i = 1 To 17
If a(i) > -1 Then
j = j + 1
If j = 3 Then
j = 0
Print a(i)
a(i) = -1
k = k - 1
End If
End If
Next
Loop
Print "剩下的是:"
For i = 1 To 17
If a(i) > -1 Then
Print a(i)
Exit For
End If
Next
End Sub


1年前

相关推荐

大家在问