公鸡5元一只,母鸡3元一只,小鸡1元三只,100元钱买100只鸡,问各买多少只?我编的东东为啥不行啊???或者哪位高手给个答案。
Dim a, b, c As Integer
For c = 3 To 100 Step 3
If (a + b + c = 100) And (5 * a + 3 * b + c / 3 = 100) Then
Print a, b, c
End If
Next c
Dim a, b, c As Integer
For c = 3 To 100 Step 3
If (a + b + c = 100) And (5 * a + 3 * b + c / 3 = 100) Then
Print a, b, c
End If
Next c
for a=1 to 100
for b=1 to 100
For c = 1 To 100
If (a + b + c = 100) And (5 * a + 3 * b + c / 3 = 100) Then
Print a, b, c
End If
Next c,b,a
for a=1 to 100
for b=1 to 100
c=100-a-b
if 5 * a + 3 * b + c / 3 = 100 Then
Print a, b, c
End If
Next b,a
for a =0 to 100
for b =0 to 100
for c =0 to 100
if 5*a+3*b+c=100 and a+b+c=100 then print a ;b;c
next
next
next
print的输出结果是0 0 100
另外楼主的第一个错误是申明变量时就已经错了。