vb习题集和答案 下载本文

next j print

next I 1 2 3 end sub 4 6 程序运行后,单击command1,输出结果为: 9 3. 在窗体上画一个命令按钮command1,然后编写如下事件过程: option base 1

private sub command1_click() dim a%(3,3) for i=1 to 3 for j=1 to 3 if j>1 and i>1 then

a(i,j)=a(a(i-1,j-1),a(i,j-1))+1 else a(i,j)=i*j end if print a(i,j);‖ ―; next j print

next I 1 2 3 end sub 2 3 1 程序运行后,单击command1,输出结果为: 3 2 3

4. 在窗体上画一个命令按钮command1,然后编写如下事件过程: option base 1

private sub command1_click() dim a%(10),p(3) as integer k=5 for i=1 to 10 a(i)=i

21

next i for i=1 to 3 p(i)=a(i*i) next i for i=1 to 3 k=k+p(i)*2 next i print k end sub

程序运行后,单击command1,输出结果为:33

5. 在窗体上画一个命令按钮command1,然后编写如下事件过程: option base 1

private sub command1_click() dim a%(4,4) for i=1 to 4 for j=1 to 4 a(i,j)=(i-1)*3+j next j next i for i=1 to 4 for j=1 to 4 print a(j,i); next j

print 1 4 7 10 next I 2 5 8 11 end sub 3 6 9 12 程序运行后,单击command1,输出结果为:4 7 10 13

6. 在窗体上画一个命令按钮command1,然后编写如下事件过程: option base 1

22

private sub command1_click() dim a%(5,5) for i=1 to 3 for j=1 to 4 if j>1 and i>1 then a(i,j)=i*j end if next j next i for n=1 to 2 for m=1 to 3 print a(m,n); next m print next n

end sub 0 0 0

程序运行后,单击command1,输出结果为:0 4 6

7. 在窗体上画一个命令按钮command1,然后编写如下事件过程: private sub command1_click() dim a%(5) for i=0 to 4 a(i)=i+1 t=i+1 if t=3 then print a(i); a(t-1)=a(i-2) else a(t)=a(i) endif

if i=3 then a(i+1)=a(t-4)

23

a(4)=1 print a(i); next i end sub

程序运行后,单击command1,输出结果为:1 2 3 1 4 1 8. 在窗体上画一个命令按钮command1,然后编写如下事件过程: private sub command1_click() dim a%(3,3) dim b

b=array(1,2,3,4,5,6,7,8,9) j=1 for i=0 to 8 j=i mod 3 k=i\\3 a(j,k)=b(i) next i k=1 for j=0 to 2

print tab(3*(j+1));a(k,j); next j end sub

程序运行后,单击command1,输出结果为:2 5 8

9. 在窗体上画一个命令按钮command1,一个文本框text1,然后编写如下事件过程: private sub command1_click() dim b

b=array(34,5,13,35,9,6,42) for i=1 to ubound(b,1) if b(i)>b(i-1) then x=b(i)

for j=i-1 to 0 step -1

24