主题:这个怎么编啊~~~
daihele
[专家分:0] 发布于 2007-07-22 06:41:00
N*N的数阵 例如N=3 187 296 345 怎么输入成这样啊
最后更新于:2007-07-22 06:44:00
回复列表 (共4个回复)
沙发
Matodied [专家分:7560] 发布于 2007-07-22 07:54:00
题目没讲清楚。
板凳
daihele [专家分:0] 发布于 2007-07-22 10:57:00
就是那种绕圈的输出 例如N=3 A(1,1)=1 A(2,1)=2 A(3,1)=3 A(3,2)=4 A(3,3)=5 A(2,3)=6 A(1,3)=7 A(1,2)=8 A(2,2)=9
当N=4 A(1,1)=1 A(2,1)=2 A(3,1)=3 A(4,1)=4 A(4,2)=5 A(4,3)=6 A(4,4)=7 A(3,4)=8 A(2,4)=9 A(1,4)=10 A(1,3)=11 A(1,2)=12 A(2,2)=13 A(3,2)=14 A(3,3)=15 A(2,3)=16 谢谢 啊 清楚了吗
3 楼
Matodied [专家分:7560] 发布于 2007-07-22 14:34:00
原来是螺旋方阵。
[url=http://www.programfan.com/club/post-242581.html]这里[/url]有相关内容。
4 楼
我的电脑 [专家分:990] 发布于 2007-10-10 18:22:00
CLS
INPUT n
DIM a(n, n)
s = 1
k = n - 1
p = 0
DO
p = p + 1: a(n + 1 - s, n + 1 - s) = p
IF k = 0 THEN EXIT DO
FOR i = 1 TO k
p = p + 1: a(n + 1 - s - i, n + 1 - s) = p
NEXT i
FOR i = 1 TO k
p = p + 1: a(s, n + 1 - s - i) = p
NEXT i
FOR i = 1 TO k
p = p + 1: a(i + s, s) = p
NEXT i
k = k - 1
IF k = 0 THEN EXIT DO
FOR i = 1 TO k
p = p + 1: a(n + 1 - s, i + s) = p
NEXT i
s = s + 1: k = k - 1
LOOP
FOR i = 1 TO n: FOR j = 1 TO n
PRINT USING "####"; a(i, j);
NEXT j: PRINT : NEXT i: END
我来回复