第7章VB习题及答案

第7章 习题与答案

一、 选择题

1.如下数组声明语句,正确的是

(A)Dim a[3,4]As Integer (B)Dim a(3,4)As Integer (C)Dim a(n,n) As Integer (D)Dim a(3,4)As Integer 2.要分配存放如下方阵的数据:

1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9

数组声明语句能实现(不能浪费空间)的是

(A) Dim a(9) As Single (B)Dim a(3,3) As Single (C)Dim a (-1 To 1,-5 To -3) As Single (D)Dim a (-3 To 1,-5 To 7) As Integer 3.如下数组声明语句: Dim a(3,-2 To 2,5) 则数组a包含的元素的个数为

(A)120 (B)75 (C)60 (D)13 4.以下程序 Dim a

a=Array(1,2,3,4,5,6,7) For i=Lbound (a) To Ubound (a) a(i)=a(i)*a(i) Next i

Print a(i) 输出结果是

(A)49 (B)0 (C)不确定 (D)程序出错 5.以下程序 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 End Sub 输出结果是

(A)1 2 3 (B)1 2 3 (C)1 2 3 2 3 1 1 2 3 2 4 6 2 2 2 3 2 3 1 2 3 3 6 9 3 3 3 6.以下程序

D)1 1 1

Option Base 1

Private Sub Command1_Click() Dim a,B(3,3)

a=Array(1,2,3,4,5,6,7,8,9) For i=1 To 3 For j=1 To 3 B(i,j)=a(i*j)

If(j>=i) Then Print Tab(j*3);format(B(i,j),“###”); Next j Print Next I End Sub 输出结果是

(A)1 2 3 (B)1 (C)1 4 7 (D)1 2 3 4 5 6 4 5 2 4 6 4 6 7 8 9 7 8 9 3 6 9 9 7.要存储n个单精度数,下列语句正确的是

(A)n=InputBox(“input n”) (B)Dim a()As Single Dim a (1 To n)As Single n=InputBox(“input n”) ReDim a(1 To n) (C)Dim a()As Integer (D)Dim a(n)As Single n=InputBox(“input n”) ReDim a(n) Single

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4