vb编程150盏灯的问题
150盏灯,初始全亮,先是拉一下是3的倍数的灯的开关,再拉一下是5的倍数的灯的开关,请问还有多少盏灯亮着呢?...
150盏灯,初始全亮,先是拉一下是3的倍数的灯的开关,再拉一下是5的倍数的灯的开关,请问还有多少盏灯亮着呢?
展开
1个回答
展开全部
Private Sub Command1_Click()
Dim n As Integer
n = 0
For i = 0 To 149
If (i + 1) Mod 3 = 0 Then
If Shape1(i).FillColor = &H0& Then
Shape1(i).FillColor = &HFFFFFF
Else
Shape1(i).FillColor = &H0&
End If
End If
Next i
For i = 0 To 149
If (i + 1) Mod 5 = 0 Then
If Shape1(i).FillColor = &H0& Then
Shape1(i).FillColor = &HFFFFFF
Else
Shape1(i).FillColor = &H0&
End If
End If
Next i
For i = 0 To 149
If Shape1(i).FillColor = &H0& Then n = n + 1
Next i
Print n
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询