- 11
- 0
- 约1.03万字
- 约 17页
- 2017-12-22 发布于河南
- 举报
程序填空(总)
程序填空(总)
【试题2】n个人围成一圈(编号为1-n),从第1号的人开始从1报数,凡报到3的倍数的人
离开圈子,然后再数下去,直到最后只剩一个人为止。问当n=17时,剩下的人
是多少号?
Private Sub Form_Click()
Const OUT As Integer = -1
Dim n As Integer,m As Integer,i As Integer,num1 As Integer,num2 As Integer
Dim a() As Integer
n = 17
m = 3
ReDim a(n)
For i = 1 To n
a(i) = i
Next
num1 = 0
Do
For i = 1 To n
If a(i) OUT Then
Num1 = num1 + 1
If num1 Mod m = 0 Then
num2 = num2 + 1
If num2 = n Then
Print a(i);
Exit Do
End If
________________
End If
End If
Next i
Loop
End Sub
【答案】11
【试题3】n个人围成一圈(编号为1-n),从第1号的人开始从1报数,凡报到3的倍数的人
离开圈子,然后再数下去,直到最后只剩一个人为止。问当n=37时,剩下的人
是多少号?
Private Sub Form_Click()
Const OUT As Integer = -1
Dim n As Integer,m As Integer,i As Integer,num1 As Integer,num2 As Integer
Dim a() As Integer
n = 37
m = 3
ReDim a(n)
For i = 1 To n
a(i) = i
Next
num1 = 0
Do
For i = 1 To n
If a(i) OUT Then
Num1 = num1 + 1
If num1 Mod m = 0 Then
num2 = num2 + 1
If num2 = n Then
Print a(i);
Exit Do
End If
________________
End If
End If
Next i
Loop
End Sub
【答案】19
【试题6】求24738和24894的最大公约数。
Private Sub Form_click()
Dim a As Integer
Dim b As Integer
Dim i As Integer
Dim t As Integer
a = 24738
b = 24894
If a b Then t = a: a = b: b = t
i = a
Do While _______________________________
i = i - 1
Loop
Print i
End Sub
【答案】6
【试题7】求24738和24894的最小公倍数。
Private Sub Form_click()
Dim a As Integer
Dim b As Integer
Dim i As Long
a = 24738
b = 24894
i = a
Do While _____________________
原创力文档

文档评论(0)