看到这题很有意思,我也写了一个
你写的那个逻辑有问题
假设你的百鸡百钱是经典的算法,公鸡5钱,母鸡3钱,3小鸡一钱,下面的代码在VB里面调试通过。
Dim a As Integer, b As Integer, c As Integer
For a = 1 To 20
For b = 1 To 33
c = 100 - a - b
If (a + b + c = 100) And (a * 5 + b * 3 + c / 3 = 100) Then
Print a, b, c
End If
Next b
Next a