百元买百鸡VB程设计
问题描述:
百元买百鸡VB程设计
百钱买百鸡:已知公鸡一只5元,母鸡一只3元,小鸡三只一元,如一百元买100只鸡,那么公鸡、母鸡和小鸡各买多少只?
答
Dim x, y
For x = 1 To 20
For y = 1 To 33
If 5 * x + y * 3 + (100 - x - y) / 3 = 100 Then
MsgBox ("x=" & x & "y=" & y & "z=" & 100 - x - y)
End If
Next y
Next x