主题:主题:儿子参加一个BASIC培训,有题不会做,请教高手
poilkj001
[专家分:0] 发布于 2010-05-11 22:15:00
我主要是不知道如何选择不同的数做题目
1. 以不同的字母代表0-9之间的数字,现有如下等式成立:a+bc+def=ghij 编程求出满足上述条件等式的个数并将所有等式打印输出.
2.将5,6,7,8,9填入(口口口*口口)的空格中,使他们的积有最大值!
3.已知四个小朋友:甲,乙,丙,丁,体重都是整数公斤,且甲<乙<丙<丁,又四人中任何两人体重和如下:35,39,44,45,50,54,请计算一下甲乙丙丁的体重各各自究竟是多少?
4.在2,3,5,7,9这五个数中选取四个数组成被3和5除都余2的四位数,这样四位数有什么?
[em58]
3 楼
njbkw [专家分:30] 发布于 2010-05-21 09:44:00
第一题答案:
s=0
g = 1
h = 0
d = 9
FOR a = 2 TO 8
FOR b = 2 TO 8
FOR c = 2 TO 8
FOR e = 2 TO 8
FOR f = 2 TO 8
FOR i = 2 TO 8
FOR j = 2 TO 8
IF (a + b + c + d + e + f + g + h + i + j = 45) AND (a * b * c * d * e * f * g * i * j = 362880) AND (a + b * 10 + c + d * 100 + e * 10 + f = g * 1000 + h * 100 + i * 10 + j) THEN
PRINT a; "+"; b * 10 + c; "+"; d * 100 + e * 10 + f; "="; g; h; i; j
s = s + 1
END IF
NEXT
NEXT
NEXT
NEXT
NEXT
NEXT
NEXT
PRINT s
END
打印格式你调整一下就可以了
4 楼
FFKK [专家分:1610] 发布于 2010-07-13 17:29:00
s=0
g = 1
h = 0
d = 9
FOR a = 2 TO 8
FOR b = 2 TO 8
FOR c = 2 TO 8
FOR e = 2 TO 8
FOR f = 2 TO 8
FOR i = 2 TO 8
FOR j = 2 TO 8
IF (a + b + c + d + e + f + g + h + i + j = 45) AND (a * b * c * d * e * f * g * i * j = 362880) AND (a + b * 10 + c + d * 100 + e * 10 + f = g * 1000 + h * 100 + i * 10 + j) THEN
pRINT a; "+"; b * 10 + c; "+"; d * 100 + e * 10 + f; "="; g; h; i; j
s = s + 1
END IF
NEXT
NEXT
NEXT
nEXT
NEXT
NEXT
NEXT
PRINT s
END