主题:请高手进来帮我看下这些题怎么做
xxpeng9420
[专家分:0] 发布于 2008-11-29 15:49:00
1.用100元买100只鸡,母鸡3元1只,小鸡1元3只,问各应买多少只?
2.取一元,二元,五元的硬币共十枚,付给25元钱,有多少种不同的取法?
两道题..麻烦好心人帮我写下.我不会
回复列表 (共3个回复)
沙发
xxmw [专家分:50] 发布于 2008-11-29 23:55:00
DIM i, j, k, a AS Integer
a = 0
PRINT "1元", "2元", "5元"
FOR i = 0 TO 10
FOR j = 0 TO 10
FOR k = 0 TO 10
IF i + j + k = 10 AND i + j * 2 + k * 5 = 25 THEN
a = a + 1
PRINT i, j, k
ENDIF
NEXT
NEXT
NEXT
PRINT a; "种方法"
----------------------------------------------------
1元 2元 5元
1 7 2
4 3 3
2种方法
板凳
xxmw [专家分:50] 发布于 2008-11-29 23:59:00
DIM i, j AS Integer
PRINT "母鸡", "小鸡"
FOR i = 0 TO 100
FOR j = 0 TO 100
IF i + j = 100 AND i * 3 + j / 3 = 100 THEN
PRINT i, j
ENDIF
NEXT
NEXT
------------------------------
母鸡 小鸡
25 75
3 楼
xxpeng9420 [专家分:0] 发布于 2008-11-30 10:24:00
谢谢你了..
我来回复