主题:编程题一大堆
幽灵密码
[专家分:3510] 发布于 2010-12-13 19:10:00
1.一个五位数,任意去掉其中一位,剩下的四个数随意调换可以组成很多四位数,把这些四位数中除以5和除以7余数都为2的数打印出来,并在最后打印符合条件的个数。
输入:23579
输出:9257 9527 2357 3257 5237 5
2.最高位的立方小于第二高位的平方,第二高位的立方小于第三高位的平方,以此类推,找出在n至m内所有这样的数及符合条件的个数。
输入:21,39
输出:24 25 26 27 28 29 36 37 38 39
11
输入:39,21
输出:39 38 37 36 29 28 27 26 25 24
11
最后更新于:2010-12-13 19:45:00
回复列表 (共15个回复)
11 楼
幽灵密码 [专家分:3510] 发布于 2010-12-18 12:01:00
废话,假如只是5还用输入啊
12 楼
幽灵密码 [专家分:3510] 发布于 2011-05-24 23:15:00
7.回字阵
CLS
INPUT n: DIM a(n, n)
a$ = STRING$(LEN(STR$(FIX(n / 2 + .5))), "#"): x = n
FOR t = 1 TO FIX(n / 2 + .5)
FOR i = t TO x
a(t, i) = t
a(i, t) = t
a(i, n + 1 - t) = t
a(n + 1 - t, i) = t
NEXT i: x = x - 1
NEXT t
FOR i = 1 TO n
FOR j = 1 TO n
PRINT USING a$; a(i, j);
NEXT j: PRINT
NEXT i
END
13 楼
幽灵密码 [专家分:3510] 发布于 2011-05-24 23:15:00
6.螺旋阵
CLS
INPUT n
a$ = STRING$(LEN(STR$(n * n)), "#")
DIM a(n, n)
i = 1: j = 0
DO
DO WHILE j + 1 <= n
IF a(i, j + 1) <> 0 THEN EXIT DO
x = x + 1: j = j + 1
a(i, j) = x
LOOP
DO WHILE i + 1 <= n
IF a(i + 1, j) <> 0 THEN EXIT DO
x = x + 1: i = i + 1
a(i, j) = x
LOOP
DO WHILE j - 1 > 0
IF a(i, j - 1) <> 0 THEN EXIT DO
x = x + 1: j = j - 1
a(i, j) = x
LOOP
DO WHILE i - 1 > 0
IF a(i - 1, j) <> 0 THEN EXIT DO
x = x + 1: i = i - 1
a(i, j) = x
LOOP
LOOP UNTIL x = n * n
FOR i = 1 TO n
FOR j = 1 TO n
PRINT USING a$; a(i, j);
NEXT j
PRINT
NEXT i
END
14 楼
幽灵密码 [专家分:3510] 发布于 2011-06-03 21:36:00
5.
CLS
g = 1
d = 9
h = 0
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
a(1) = a
a(2) = b
a(3) = c
a(4) = d
a(5) = e
a(6) = f
a(7) = h
a(8) = i
j2 = 10 * b + c
j3 = 100 * d + 10 * e + f
he = j2 + j3 + a
j = he - 1000 - 100 * h - 10 * i
a(9) = j
IF j < 0 OR j > 9 THEN 1
FOR x = 1 TO 8
FOR y = x + 1 TO 9
IF a(x) = a(y) THEN 1
NEXT y, x
PRINT a; "+"; j2; "+"; j3; "="; he
1 NEXT i, f, e, c, b, a
END
15 楼
幽灵密码 [专家分:3510] 发布于 2011-06-06 10:40:00
4.
CLS
INPUT n
DIM a(n, n)
i1 = 1
j1 = n
k = 1
a(i1, j1) = k
FOR i = 2 TO n * 2 - 1
IF i > n THEN i1 = i1 + 1: k = k + 1 ELSE j1 = j1 - 1: k = k + 1
a(i1, j1) = k
h = i1
l = j1
IF i <= n THEN x = i ELSE x = n * 2 - i
FOR j = 2 TO x
i1 = i1 + 1
j1 = j1 + 1
k = k + 1
a(i1, j1) = k
NEXT j
i1 = h
j1 = l
NEXT i
FOR i = 1 TO n
FOR j = 1 TO n
PRINT USING STRING$(LEN(STR$(k)), "#"); a(i, j);
NEXT j
PRINT
NEXT i
END
我来回复