Dim x, y, z
在新津县等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都做网站、网站建设 网站设计制作按需定制网站,公司网站建设,企业网站建设,品牌网站制作,成都全网营销推广,外贸营销网站建设,新津县网站建设费用合理。
Private Sub Command1_Click()
Cls
Print "小鸡", "公鸡", "母鸡"
For x = 0 To 20 Step 1
For y = 0 To 34 Step 1
If (100 - x - y) / 3 + 3 * y + 5 * x = 100 Then
z = 100 - x - y
Print z, y, x
End If
Next y
Next x
End Sub
望采纳。。。。
Private Sub Command1_Click()
For i = 1 To 20
For j = 1 To 33
For k = 1 To 99 Step 2
If i * 5 + j * 3 + k / 3 = 100 Then
Text1.Text = Text1.Text "公鸡:" i "只" "母鸡:" j "只" "小鸡:" k "只" Chr(13) Chr(10)
End If
Next
Next
Next
End Sub
文本框的MULTILING属性设为TRUE,SCROLLBARS属性设为2垂直。
以下为改进版
Private Sub Command1_Click()
For i = 1 To 20
For j = 1 To 33
k = 100 - i * 5 - j * 3
If k = 0 And k Mod 3 = 0 Then
Text1.Text = Text1.Text "公鸡:" i "只" "母鸡:" j "只" "小鸡:" k "只" Chr(13) Chr(10)
End If
Next
Next
End Sub
假设你的百鸡百钱是经典的算法,公鸡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
设小鸡x 公鸡y 母鸡z
0.5x+2y+3z=100
x+y+z=100
得出3y+5z=100-------1
3x-2z=200--------2
鸡个数要为整,由1式得出y必须要为5的倍数才能得出z也是整数y要小于35
y=5 z=17 x=78
y=10 z=14 x=76
y=15 z=11 x=74
y=20 z=8 x=72
y=25 z=5 x=70
y=30 z=2 x=68
就这几种了