主题:[讨论]难啊难! SOS
独手编程
[专家分:360] 发布于 2010-11-11 17:44:00
一根29CM长的尺子,只允许在上面刻7个刻度,要能用它量出1~29CM的各种长度。试问应怎样选择刻度?
要解说和程序
解说一帖50分
程序一帖50分
两贴都有,再发一帖灌水再加50分!
[em5][em5][em5][em5][em5]
回复列表 (共9个回复)
沙发
komer [专家分:20] 发布于 2010-11-16 12:57:00
应该用循环
再用IF语句
最后用特殊输出
板凳
小心哦哦 [专家分:140] 发布于 2010-11-23 19:47:00
幽灵密码也问了
无效!!!!
3 楼
独手编程 [专家分:360] 发布于 2010-12-01 17:51:00
发广告的
滚蛋
滚滚滚滚滚
4 楼
huangyb731 [专家分:630] 发布于 2010-12-01 18:20:00
用if+for
5 楼
huangyb731 [专家分:630] 发布于 2010-12-02 18:36:00
啊
6 楼
王19991122 [专家分:70] 发布于 2010-12-03 13:41:00
应该用for/next语句吧!
7 楼
幽灵密码 [专家分:3510] 发布于 2011-05-24 23:36:00
CLS
DIM s(28), m(7)
s = TIMER
FOR a = 1 TO 22
FOR b = a + 1 TO 23
FOR c = b + 1 TO 24
FOR d = c + 1 TO 25
FOR e = d + 1 TO 26
FOR f = e + 1 TO 27
FOR g = f + 1 TO 28
n = 1
m(1) = a
m(2) = b: m(3) = c: m(4) = d: m(5) = e: m(6) = f: m(7) = g
FOR j = 7 TO 1 STEP -1
s(29 - m(j)) = 1
FOR k = j - 1 TO 1 STEP -1
s(m(j) - m(k)) = 1
NEXT k, j
s(a) = 1
s(b) = 1: s(c) = 1: s(d) = 1: s(e) = 1: s(f) = 1: s(g) = 1
FOR i = 1 TO 28
IF s(i) = 0 THEN n = 0: EXIT FOR
NEXT i
IF n <> 0 THEN PRINT a; b; c; d; e; f; g
FOR i = 1 TO 28
s(i) = 0
NEXT i
NEXT g, f, e, d, c, b, a
PRINT "Use time"; TIMER - s; "seconds"
END
8 楼
孙瑞 [专家分:590] 发布于 2011-05-25 19:15:00
卡死我的电脑了!建议用线性代数的方法去解决!
9 楼
幽灵密码 [专家分:3510] 发布于 2011-05-26 17:46:00
线性?Qbasic好像没有指针变量吧?
我来回复