百钱百鸡VB编程,代码?
***设你的百鸡百钱是经典的算法,公鸡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
用伪代码写出母鸡每只3元,公鸡2元,小鸡0.5元,百元买百鸡?
int x=1,y=1;
z=100-x-y;
for(x=1;x
for(y=1;z>=1;y++)
如果3*x+2*y+0.5*z=100且x+y+z=100,输出x,y,z
结束