vb 編寫程式解決百錢買百雞問題

2021-05-03 21:54:36 字數 1312 閱讀 5852

1樓:匿名使用者

private sub command1_click()dim cock, hen, chicken, sum as integer

for cock = 0 to 19

for hen = 0 to 33

chicken = 100 - cock - henif not (c mod 3) thensum = cock * 5 + 3 * hen + chicken / 3

if sum = 100 then

print "公雞" & cock, "母雞" & hen, "小雞" & chicken & vbnewline

end if

end if

next

next

end sub

2樓:

private sub command1_click()dim a, b, c as integerdim aconst, bconst as integerdim sum as integer

aconst = int((100 - (100 / 3)) / 5) + 1

for a = 0 to aconst

bconst = int((100 - a * 5) / 3) + 1

for b = 0 to bconst

c = 100 - a - b

if not (c mod 3) thensum = a * 5 + 3 * b + c / 3if sum = 100 then

print "公雞" & a, "母雞" & b, "小雞" & celseif sum > 100 thenexit for

end if

end if

next

next

end sub

寫程式解決百錢買百雞問題:公雞3元1只,母雞5元1只,小雞1元3只,怎樣用100元買100只雞。把 20

3樓:悠yo悅靈

dim x, y, z

private sub command1_click()clsprint "小雞", "公雞

版", "母雞

權"for x = 0 to 20 step 1for y = 0 to 34 step 1if (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

用vb編寫程式,計算

option explicitdim k,t as singleprivate sub mand1 click for k 2 to 300 step 2t t 1 k next label1.caption t end sub for i 2 to 300 step 2 sum 1 i sum n...

vb程式題急謝謝編寫程式從文字框輸入與

設text1和text2分別為x和y的輸入框,text3輸出結果,另有 mand1是計算按鈕。在窗體代版碼 通權用 段編寫函式過程 private function f byval x as double,byval y as double as double select case x case ...

幾百塊的平板電腦能買嗎,幾百塊錢的平板電腦有哪些?

我700塊買了個,一直用的蠻好的,看看電子書 玩玩小遊戲 看看電影 偶爾處理下文件,看看網頁,夠用就行了。幾百塊錢的平板電腦有哪些?幾百塊平板電腦就是大一點的安卓手機就是不能裝卡!平板電腦幾百塊錢的好不好 先看牌子,在看配置,在看做工。幾百的平板我買過 是酷比魔方的 用到現在還能用。不好!在中國便宜...