VB简单的算术题,帮忙..

来源:百度知道 编辑:UC知道 时间:2024/05/14 16:19:05
公鸡5块钱一只, 母鸡3块钱一只, 小鸡1块钱3只,现有100块钱..

用vbs脚本怎么算出来有几种买法呀..?

顺便说下原理哈,谢谢了..
谢谢" 570851835"的答复,运行不了哈..

错误提示:类型不匹配:'print'
你那vbs运行没问题吗..?

<%
Dim gprice, mprice, xprice, gcount, mcount, xcount, count
gprice = 5
mprice = 3
xprice = 3

For gcount = 1 To 100 \ gprice
If (100 - gprice * gcount) \ mprice <> 0 Then
For mcount = 1 To (100 - gprice * gcount) \ mprice
If 100 - gprice * gcount - mcount * mcount <> 0 Then
xcount = (100 - gprice * gcount - mcount * mcount) * xprice
response.write "一共可买了" & gcount & "只公鸡," & mcount & "只母鸡" & xcount & "只小鸡" & "<br>"
count = count + 1
End If
Next
End If
Next
response.write "一共有" & count & "种买法"
%>

最后的结果是309种买法,写错了,我是用vb写的,改成上面那样就行了,把print改成response.write。你所说的vbs是不是vbscript?如果是的话,就没有错