(QBasic)一只公鸡5元,一只母鸡3元,三只小鸡一元.用100元买100只鸡,问公鸡,母鸡,小鸡一共买了多少只?
问题描述:
(QBasic)一只公鸡5元,一只母鸡3元,三只小鸡一元.用100元买100只鸡,问公鸡,母鸡,小鸡一共买了多少只?
答
CLSFOR a = 1 TO 20FOR b = 1 TO 33FOR c = 3 TO 99 STEP 3IF a + b + c = 100 THEN IF 5 * a + 3 * b + c / 3 = 100 THEN PRINT "gongji:"; a, "muji:"; b, "xiaoji:"; cend ifend ifNEXT ...