VB编程求鸡兔同笼问题

2024-12-25 06:45:30
推荐回答(1个)
回答1:

Private Sub Command1_Click()
'鸡兔同笼问题
Dim Cock As Integer
Dim Rab As Integer
For Cock = 0 To 100
Rab = 100 - Cock
If Cock * 2 + Rab * 4 = 300 Then
Print "其中鸡有" & Cock & "只,兔子有" & Rab & "只"
End If
Next
End Sub