1樓:
追問一下,要買幾隻雞??
不確定的話,有很多種方案啊
private sub command1_click()dim xiao as integer, mu as integer, gong as integer
dim i as integer
for xiao = 0 to 300
for mu = 0 to 33
for gong = 0 to 20
if xiao / 3 + mu * 3 + gong * 5 = 100 then
i = i + 1
print "方案" & i & "你可以用一百塊購買" & xiao & "只小雞," & mu & "只母雞," & gong & "只公雞"
end if
next gong
next mu
next xiao
print "總計共有" & i & "種方案"
end sub
2樓:匿名使用者
private sub form_click()dim g, m, x as integerfor g = 0 to 20
for m = 0 to 33
for x = 0 to 100
if g + m + x = 100 and g * 5 + m * 3 + x / 3 = 100 then
list1.additem "公雞" & g & "母雞" & m & "小雞" & x
end if
next x
next m
next g
end sub
在窗體上加一個列表框 名為 list1
謝謝,可以了不?
3樓:匿名使用者
private sub command1_click()dim i as integer, j as integer, k as integer, n as integer
for i = 1 to 300
if i mod 3 = 0 then
for j = 1 to 33
for k = 1 to 20
if i \ 3 + 3 * j + 5 * k = 100 then
debug.print "xj:" & i, "mj:" & j, "gj:" & k
n = n + 1
end if
next k
doevents
next j
end if
next i
debug.print "fa:" & nend sub
4樓:匿名使用者
如果說是三次迴圈一樣的是4的4次方
3元兩隻公雞,2元一隻母雞,1元兩隻小雞,現給100元錢,要求買100只雞,問有幾種買法?用列舉法程式設計求解
var x,y,z integer begin for x 0 to 100 do for y 0 to 100 do for z 0 to 100 do if x y z 100 and x 3 y 2 z div 3 100 and z mod 3 0 then writeln x x,y y,...
100元買100只雞,5元一隻公雞,3元一隻母雞,一元三隻小雞,求公雞,母雞,小雞各買幾隻
設公雞a只,母雞b只,通過計算一共有三組答案,如下 1.公雞,母雞,小雞各買4只,18只,78只 2.公雞,母雞,小雞各買8只,11只,81只 3.公雞,母雞,小雞各買12只,4只,84只 四個公雞十八個母雞七十八個小雞,或八個公雞十一個母雞八十一個小雞,或十二個公雞四個母雞八十四個小雞 你要沒什麼...
100塊買100只雞,公雞2 5元一隻,母雞2 4元一隻,雞仔0 1一隻,怎么分配
設買公雞x只,母雞y只,雞仔z只,則x y z 100.2.5x 2.4y 0.1z 100.設買公雞x只,母雞y只,雞仔z只,則x y z 100.2.5x 2.4y 0.1z 100.然後討論 讓雞的 翻10倍,成為整數問題,即1000塊錢買100只雞,其中公雞25元一隻,母雞24元一隻,雞仔1...