一个2级vb的计算题 10
(05年春)执行下面程序,单击按钮command1,A(1,1)的值__,A(1,4)的值是___,A(4,1)的值___,A(4,4)的值是___optionbasic...
(05年春)执行下面程序,单击按钮command1,A(1,1)的值__,A(1,4)的值是___,A(4,1)的值___,A(4,4)的值是___
option basic 1
private sub command1_click()
dim a() as integer,i as integer,j as integer
dim k as integer,n as integer
n=4
redim a(n,n)
i = 1:j = n: a(i,j)=1
for k=2 to n*n
if i+1>n then
i=n-j+2:j=1
elself i+1<=n and j+1>n then
j=j-i:i=1
else
i=i+1:j=j+1
end if
a(i,j)=k
next k
for i = 1 to n
for j = 1 to n
print a(i,j)
next j
print
next i
end sub
困惑:前三个数很easy,但是最后一个,虽然可以猜到,但是还是不能肯定
还是做到了最后,算出来的。偶层次不够,高手怎么能一下看出来吗? 展开
option basic 1
private sub command1_click()
dim a() as integer,i as integer,j as integer
dim k as integer,n as integer
n=4
redim a(n,n)
i = 1:j = n: a(i,j)=1
for k=2 to n*n
if i+1>n then
i=n-j+2:j=1
elself i+1<=n and j+1>n then
j=j-i:i=1
else
i=i+1:j=j+1
end if
a(i,j)=k
next k
for i = 1 to n
for j = 1 to n
print a(i,j)
next j
next i
end sub
困惑:前三个数很easy,但是最后一个,虽然可以猜到,但是还是不能肯定
还是做到了最后,算出来的。偶层次不够,高手怎么能一下看出来吗? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询