若要定义一个10个元素的整数数组,每个元素的值均为5,则下列语句正确的是___________。
A: Dim a%(9) = 5
B: Dim a%(10) = 5
C: Dim a%(9) = (5)
D: Dim a%(9), i% For i = 0 To 9 a(i) = 5 Next
A: Dim a%(9) = 5
B: Dim a%(10) = 5
C: Dim a%(9) = (5)
D: Dim a%(9), i% For i = 0 To 9 a(i) = 5 Next
举一反三
- 下列数组声明语句中正确的是( )。 A: Dim A(9) As Single = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } B: Dim A( ) As Single = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } C: Dim A( ) As Single = { 1, "abc", "ccc", 4, 5, 6, 7, 8, 9, 10 } D: Dim A( , ) As Single = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
- 若有数组Dim a%(10)且每个元素有值,统计前一个元素大于后一个元素的次数,结果存放在变量n中。则下列语句正确的是___________。 A: Dim i%, n% For i = 1 To 10 If a(i) > a(i + 1) Then n = n + 1 End If Next MsgBox(n) B: Dim i%, n% For i = 1 To 10 If a(i) > a(i + 1) Then n = a(i) End If Next MsgBox(n) C: Dim i%, n% For i = 0 To 9 If a(i) > a(i + 1) Then a(i) = n + 1 End If Next MsgBox(n) D: Dim i%, n% For i = 0 To 9 If a(i) > a(i + 1) Then n = n +1 End If Next MsgBox(n)
- 下列数组声明语句中,不正确的是_________。 A: Dim a(9) As Single = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} B: Dim a() = {1, 2, 3, 4, 5, 6, 10} C: Dim a( ,) As Single = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}} D: Dim a() As Single = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} E: Dim n As Integer=10Dim a(n) As Single
- 用语句 Dim A(-3 to 5)As Long 定义的数组元素个数是( )。 A: 7 B: 10 C: 8 D: 9
- 执行以下程序段后,数组b中的元素个数有________个。Dim a() As Integer = {2, 15, 9, 4, 5, 56, 74, 8, 43, 10}Dim b(9) As IntegerDim count As Integer = 0Dim i As IntegerFor i = 0 To UBound(a)If a(i) Mod 2 = 0 Thenb(count) = a(i)count += 1End IfNextReDim Preserve b(count - 1)